# Power BI: IPL Analytics- Data Modeling and Transformation-Part 2

In my previous blog we have seen few techniques of data modeling. Now let us  see few more techniques to do the data modeling and data transformation

We have Match table which has all match related details such as winner team, who is the man of the match, is the match won by wickets or runs etc. If we would like to show the data “Win by wickets” and “Win By Runs” based on the winning type, how do we do that?  Just open the table. See there are two columns (Win Type and  Win Margin) which can provide such data, we only need to show this data from columns to the rows.

Let us add new column called Win_By_Wickets and add the formula to show the win_margin in case the match is won by wickets.

Let us follow the steps as shown in below snippets Add the column name before the “=” symbol and let us add if condition to check the win_type and display the Win_Margin, Writing this DAX formula is almost similar to how we add formula in excel. The complete formula would be

“Win_By_Wickets = IF(Match[Win_Type]=”wickets”,Match[Win_Margin],”0″)”

Similarly for Win by Runs, it would be

Win_By_Runs = IF(Match[Win_Type]=”runs”,Match[Win_Margin],”0″)

Now we have these two new columns added in the table for further visualization purpose. Aggregate the data with group by

Ball By Ball table contains the huge data per ball in all the matches. Now if we need to find the statistics of Economy Rate – how many runs the Bowler has given per over. We can use SUMMARIZE function which provides grouping of the data based on particular columns. Output of the summarize function is a table. Its very similar to the select query having group by clause and aggregate function in the SQL server. Please refer below expression which selects data from Ball_By_Ball table, groups the data by Bowler and adds additional columns to the same table with various aggregate functions such as SUM, COUNTROWS etc.

EconomyTable = SUMMARIZE(Ball_By_Ball,Ball_By_Ball[Bowler],”Runsperbowler”,SUM(Ball_By_Ball[Runs_Scored]),”Oversbybowler”,COUNTROWS(Ball_By_Ball)/6,”Economy”,(SUM(Ball_By_Ball[Runs_Scored])/(COUNTROWS(Ball_By_Ball)/6))) Here we are calculating the economy rate, hence need the number of overs played by the Bowler and the runs scored,

My Economy column contains the formula as RunsperBowler divided by oversbyBowler. Exact formula is as given below (SUM(Ball_By_Ball[Runs_Scored])/(COUNTROWS(Ball_By_Ball)/6)))

Now we can use this table in report for further visualizations. I would recommend everyone to go to the Microsoft Docs (Link is provided below) to refer the details of the different aggregate functions available in Power BI.

Aggregates in Power BI visualizations

We have seen few more techniques of data modeling in Power BI using Power BI desktop in this blog. Let us see how to create different visualizations of this data and create IPL Analytics reports in my next blog. I just loved creating these reports.

Thank you for reading my blog, if you have any questions please mention in the comments and hit the like button if you like my write up.

Keep Learning !! Happy analyzing and be Powerful 🙂

Power BI: Licensing Overview

Power BI: IPL Analytics- Dashboard

Power BI: Measures Vs Calculated Column

Power BI Jargons: DAX/M/Power Query

Power BI: IPL Analytics- Visualizations and Design Reports -Part 7

Power BI: IPL Analytics- Visualizations and Design Reports -Part 6

Power BI: IPL Analytics- Visualizations and Design Reports -Part 5

Power BI: IPL Analytics- Visualizations and Design Reports -Part 4

Power BI: IPL Analytics- Visualizations and Design Reports -Part 3

Power BI: IPL Analytics- Visualizations and Design Reports -Part 2

Power BI: IPL Analytics- Visualizations and Design Reports -Part 1

Power BI: IPL Analytics- Data Modeling and Transformation-Part 2

Power BI: IPL Analytics- Data Modeling and Transformation-Part 1
{"ft_lang_label":"__label__en","ft_lang_prob":0.8816747,"math_prob":0.78574854,"size":3948,"snap":"2021-43-2021-49","text_gpt3_token_len":929,"char_repetition_ratio":0.14781947,"word_repetition_ratio":0.07754443,"special_character_ratio":0.21251267,"punctuation_ratio":0.083798885,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9646172,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,9,null,9,null,9,null,9,null,9,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-21T04:15:53Z\",\"WARC-Record-ID\":\"<urn:uuid:a364a8cc-0fab-4b00-a481-99c6f66d515e>\",\"Content-Length\":\"194886\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:75a00dce-8535-4e0e-ae69-36340db8da2c>\",\"WARC-Concurrent-To\":\"<urn:uuid:15a7a2b3-b724-4e29-9921-3488a23c4b2d>\",\"WARC-IP-Address\":\"192.0.78.25\",\"WARC-Target-URI\":\"https://vrushaliranjalkar.blog/2018/08/29/power-bi-ipl-analytics-data-modeling-and-transformation-part-2/\",\"WARC-Payload-Digest\":\"sha1:4WABTW3WZ2ZZKK2G2DHKOVRZEC4SV5CY\",\"WARC-Block-Digest\":\"sha1:5UT43COQ7NTWQVQWYOL5BRTPONWZI3BC\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585381.88_warc_CC-MAIN-20211021040342-20211021070342-00465.warc.gz\"}"}