Forum Discussion
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
| Region | Sales |
| North | 30000 |
| South | 20000 |
| East | 15000 |
| West | 45000 |
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:
| Region | TargetAccomplished |
| North | 80% |
| South | 70% |
| East | 70% |
| West | 80% |
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
Super User
try the below,
Total Sales = SUM('Table'[Sales])Sales % = VAR _Allsales = CALCULATE([Total Sales],ALL('Table')) return DIVIDE([Total Sales],_Allsales)Thanks,
Arul
- AnonymousNot 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