Forum Discussion
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
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
Anonymous 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:
8 Replies
- AllisonKennedyCommunity Champion
Anonymous 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:
- AnonymousNot applicable
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.
- AllisonKennedyCommunity Champion
Anonymous 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.
- AllisonKennedyCommunity Champion
Anonymous Do you have a DimDate and DimCountry table?
https://excelwithallison.blogspot.com/2020/08/its-complicated-relationships-in-power_11.html
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.
- Ashish_MathurSuper 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?