Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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 DateCall YearCall MonthMonth NameMonthPMNMoUMBTMD.COUNTRYStd Target 
1/1/20212021202101Jan1ALBEM0.0833330Albania0% 
1/1/20212021202101Jan1ALBVF173.51671251.777Albania100% 
1/1/20212021202101Jan1ALBAM10.716670Albania0% 
1/1/20212021202101Jan1ALBVF623.016729903.94Albania100% 
1/1/20212021202101Jan1ALBAM 4935.924Albania0% 
1/1/20212021202101Jan1ALBAM 0Albania0% 
1/1/20212021202101Jan1ALBAM 0Albania0% 

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 :

DateALBAMALBEMALBVFGrand TotalALBAM %ALBEM %ALBVF  %
1/1/2021493603115636091.6414%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

  • AllisonKennedy's avatar
    AllisonKennedy
    Community 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: 
     

     


     

     
    • Anonymous's avatar
      Anonymous
      Not 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.

       

       

      • AllisonKennedy's avatar
        AllisonKennedy
        Community 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.

  • 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?