cancel
Showing results for
Did you mean:
Helper I

## Calculations on Summarized columns

Hello,

Reading/Watching articles, questions, I learnt about Summarize and found it appropriate for my usage. Am stuck at a point. Hope some one could help me.

My original data is :

 Call Date Call Year Call Month Month Name Month PMN MoU MB TMD.COUNTRY Std Target 1/1/2021 2021 202101 Jan 1 ALBEM 0.083333 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBVF 173.5167 1251.777 Albania 100% 1/1/2021 2021 202101 Jan 1 ALBAM 10.71667 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBVF 623.0167 29903.94 Albania 100% 1/1/2021 2021 202101 Jan 1 ALBAM 4935.924 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBAM 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBAM 0 Albania 0%

There are more dates.

I want is - 1) total of MB for each PMN of each Date.  2) Total of MB for each Country of each Date  3) Divide the TotalByCountry / TotalPerPMN and save it as a percentage.

I started up with a Summarize table:

``````Summary_MB =
SUMMARIZE(OutboundVolumes,
OutboundVolumes[Call Date],
OutboundVolumes[TMDPartners.COUNTRY],
OutboundVolumes[PMN (SYN)],
"TotalMBs", SUM(OutboundVolumes[Real Volume (MB)]),
"TotalMoUs", SUM(OutboundVolumes[Real MoU])
) ``````

This gives me my (1) total of MB for each PMN of each Date

For Total for each Country by Date, I need to GroupBy CallDate, & Country, and SUM(TotalMBs). I couldn't figure out to do this part in the above Summarize command, so made another table (though wanted in the same table Summary_MB 😞 😞

``````Summary_MB_Country =
SUMMARIZE(Summary_MB,
Summary_MB[Call Date],
Summary_MB[TMDPartners.COUNTRY],
"TotalMBsPerCountrty", SUM(Summary_MB[TotalMBs])
)``````

And this gives me perfect result:

I did get the sum of MB column for each PMN & Country based on Date - though they both are in different tables.

Now, I got to divide

Summary_MB_Country[TotalMBsPerCountrty] /  Summary_MB[TotalMBs]
for each country based on date and store the value in a column.

Tried Addcolumn in the Summary_MB table, Add measure, but nothing gives the expected results. Expected result is :

 Date ALBAM ALBEM ALBVF Grand Total ALBAM % ALBEM % ALBVF  % 1/1/2021 4936 0 31156 36091.64 14% 0% 86%

Can anyone here help me figure out how do I accomplish this.

Any help is appreciated.

Thank you

1 ACCEPTED SOLUTION
Super User

@td_beginner  I see no one has come back with a more detailed reply and I have a bit more time now, so please see attached pbix file below my signature.

I have created Dimension tables for your for Date, Country and PMN as this will make your life easier in the long run. I referenced the OutboundVolumes table to generate these (see my video on survey data for something similar) but ideally you'd have this in your data source already and can pull into Power BI.

Then I created a simple measure for Total MB:

Total MB = SUM(OutboundVolumes[MB])

Then I created a measure to get Total MB for ALL PMN (when you configure the visual correctly this will give you the total per Country and Date);

Total MB all PMN =
IF([Total MB] <> BLANK(),
CALCULATE([Total MB], All(PMN))
)

Finally, I divided these:

% of MB by Total MB all PMN = DIVIDE([Total MB], [Total MB all PMN])

Using the Matrix visual, you have your desired column:

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

8 REPLIES 8
Super User

@td_beginner  I see no one has come back with a more detailed reply and I have a bit more time now, so please see attached pbix file below my signature.

I have created Dimension tables for your for Date, Country and PMN as this will make your life easier in the long run. I referenced the OutboundVolumes table to generate these (see my video on survey data for something similar) but ideally you'd have this in your data source already and can pull into Power BI.

Then I created a simple measure for Total MB:

Total MB = SUM(OutboundVolumes[MB])

Then I created a measure to get Total MB for ALL PMN (when you configure the visual correctly this will give you the total per Country and Date);

Total MB all PMN =
IF([Total MB] <> BLANK(),
CALCULATE([Total MB], All(PMN))
)

Finally, I divided these:

% of MB by Total MB all PMN = DIVIDE([Total MB], [Total MB all PMN])

Using the Matrix visual, you have your desired column:

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helper I

wow, great @AllisonKennedy . Thanks a lot.

Your detailed explaination and pibx file help me achieve this big requirement (for me 🙂 ).

Your blog  is also great, has so much detail.

I want to show the PMNs with 0 Total MB/Total MB all PMN of a Country. I tried the IF clauses, but that brings up all the PMNs. Any way that we can show up 0% for any of the Total is 0 or blank.

Thanks a lot.

I highly appreciate your guidance and support.

Super User

@td_beginner You're welcome.

In order to show 0% you will either get all PMNs displayed as you have already discovered, or you need to specify which PMNs you want to see somehow. Can you explain this in further detail?

Other option would be to use Power Query - so click 'Transform Data' to open Power Query, then in the Tranform tab > Replace values. Replace null with 0.

This will then carry through to the formula.

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helper I

Hello @AllisonKennedy ,

There are few nulls in Country field, which I have filtered out.

The see the issue - the OutboundVolume is merged with TMD table that gives Country. TMD contains all PMNs which may not be in the OutboundVolumes. Those PMNs, even if merged with OutboundVolumes, would contain no data for Dates, MB, or any relevant field. On by filtering Date, dataset could not have those PMNs, as the value for CallDate is null.

Doing a Left Join, I have grabbed the Country and Std Target from the TMD into OutboundVolumes.

It's like, "ALBEM" is for 1/1/21, but not for 1/2/21, so for 1/2/21, it doesn't show ALBEM.

 Call Date Call Year Call Month Month Name Month PMN MoU MB TMD.COUNTRY TMD.Std Target 1/1/2021 2021 202101 Jan 1 ALBEM 0.083333 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBVF 173.5167 1251.777 Albania 100% 1/1/2021 2021 202101 Jan 1 ALBAM 10.71667 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBVF 623.0167 29903.94 Albania 100% 1/1/2021 2021 202101 Jan 1 ALBAM 4935.924 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBAM 0 Albania 0% 1/1/2021 2021 202101 Jan 1 ALBAM 0 Albania 0% 1/2/2021 2021 202101 Jan 1 ALBVF 353.8 10586.44 Albania 100% 1/2/2021 2021 202101 Jan 1 ALBAM 25.33333 12.27256 Albania 0% 1/2/2021 2021 202101 Jan 1 ALBVF 314.6 24669.91 Albania 100% 1/2/2021 2021 202101 Jan 1 ALBAM 3019.622 Albania 0% 1/2/2021 2021 202101 Jan 1 ALBAM 147.5871 Albania 0% 1/2/2021 2021 202101 Jan 1 ALBAM 0 Albania 0% 1/2/2021 2021 202101 Jan 1 ALBAM 0 Albania 0%

The Country & Std Target taken from TMD contains:

 PMN Country Target ALBEM Albania 0% ALBVF Albania 5% ALBAM Albania 95%

Could we possibly show all the partners from the TMD for each date regardless of the data being available in the OutboundVolumes. If there is no data, then we show 0.

Hope this helps.

Thank You,

Super User

@td_beginner  Can you please share a screenshot of your model view? You're on the right track with a Left Outer join - I'm just a bit lost with all the tables and abbreviations you mentioned, so need the model view to visualize what we're working with please. 🙂

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helper I

Hello @AllisonKennedy

My Model diagram:

By Creating the PMN table from TMD[PMN], I could atleast show all PMN in the dropdown list, but doesn't show in the chart or the Matrix.

3 PMN for Albania country are - ALBAM, ALBEM, and ALBVF

Thank you

Super User

Hi,

Why are you creating a calculated table?  A calculated table does not respond to a change in slicers?  Why not write measures and drag those to your visual?

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

@td_beginner  Do you have a DimDate and DimCountry table?

I would suggest using the CALCULATE and ALL functions to get the total per date and country, as MEASURES, then just do a simple DIVIDE function to get the percent.

Please @mention me in your reply if you want a response.

Check out my Tokyo 2020 report with live stats - KUDOS much appreciated

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Announcements

#### Launching new user group features

Learn how to create your own user groups today!