Forum Discussion

pranshuagrawal's avatar
pranshuagrawal
Regular Visitor
4 years ago

How to get Total of a Measure

I can either use a Categorical Data View Mapping or a Table Mapping, my question is how can I get Total Value of a Measure in my custom visual?

 

For ex. User has entered Region and Sales. And the data looks like

RegionSales
North30000
South20000
East15000
West45000

 

I just want to calculate the total of the sales. (which should be 110,000). I know I can just iterate over this data and add it but this approach fails when I have percentage related data in Measure. For ex:

 

RegionTargetAccomplished
North80%
South70%
East70%
West80%

 

And the total here should be 75% and not 300% (which is what I will get if I am iterating over all the values and summing it up). Let me know if there is anyway to achieve the total if I am using Categorical / Table data view mapping.

2 Replies

  • Arul's avatar
    Arul
    Icon for Super User rankSuper User

    pranshuagrawal ,

    try the below,

    Total Sales = SUM('Table'[Sales])
    Sales % = 
    VAR _Allsales = CALCULATE([Total Sales],ALL('Table'))
    return DIVIDE([Total Sales],_Allsales)

    Thanks,

    Arul

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi pranshuagrawal ,

    In order to give you suitable soltuion, could you please provide the calculation logic which how to get 75% base on your sample data? Thank you.

    75%=xxx/xxx+xxx/xxx+...?

     

    Best Regards