Forum Discussion
Filter function for calculating % of total
Dear All,
I need to create a DAX measure for calculating % of a group of customers compared to the total.
That's the mathematical logic: (OB-EX + OB-SH)/(OB-EX + OB-SH+ #)
| Part.Type05 | Customer | Turnover |
| OB-EX | A | 72891 |
| OB-EX | B | 182818 |
| OB-SH | C | 172881 |
| OB-SH | D | 887 |
| # | E | 7533 |
| # | F | 2498 |
I used the function FILTER, but even with one variable it's not working.
How should i structure my DAX formula to get the result that i need, please?
Thanks a lot!
Hi,
Try this
Revenue = sum('OB_Local_Currency'[Turnover])
Measure1 = calculate([Revenue],'OB_Local_Currency'[Part.Type05]="OB-EX"||'OB_Local_Currency'[Part.Type05]="OB-SH")
Measure2 = DIVIDE([Measure1],[Revenue])
Drag Measure2 to a card visual.
Hope this helps.
4 Replies
- jdbuchanan71
Super User
Anonymous
It's going to look something like this.
%OB LC Customers = VAR _Numerator = CALCULATE ( SUM ( 'OB_Local Currency'[Turnover] ), ALL ( 'OB_Local Currency' ), 'OB_Local Currency'[PartType05 - SP S (M)] IN { "OB-EX", "OB-SH" } ) VAR _Denomenator = CALCULATE ( SUM ( 'OB_Local Currency'[Turnover] ), ALL ( 'OB_Local Currency' ) ) RETURN DIVIDE ( _Numerator, _Denomenator ) - v-zhangti
Community Support
Hi, Anonymous
You can try the following DAX expressions.
Measure = CALCULATE ( SUM ( 'Table'[Turnover] ), FILTER ( ALL ( 'Table' ), 'Table'[Part.Type05] = "OB-EX" || 'Table'[Part.Type05] = "OB-SH" ) ) / CALCULATE ( SUM ( 'Table'[Turnover] ), FILTER ( ALL ( 'Table' ), 'Table'[Part.Type05] = "OB-EX" || 'Table'[Part.Type05] = "OB-SH" || 'Table'[Part.Type05] = "#" ) )Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Ashish_Mathur
Super User
Hi,
Try this
Revenue = sum('OB_Local_Currency'[Turnover])
Measure1 = calculate([Revenue],'OB_Local_Currency'[Part.Type05]="OB-EX"||'OB_Local_Currency'[Part.Type05]="OB-SH")
Measure2 = DIVIDE([Measure1],[Revenue])
Drag Measure2 to a card visual.
Hope this helps.
- AnonymousNot applicable
Thanks to you and all solutions!
One of them worked for me with some small adaptations. I accepted this one as solution.