Forum Discussion
DAX help
Need help on the below scenerio: How to write a DAX?
actual table:
| Category | Value |
| A | 10 |
| B | 20 |
| C | 30 |
Out put expecting in the dashboard:
| Category | Value | % |
| A | A/C | 33% |
| B | B/C | 67% |
| Total | Measure = (A+B)/C | 100% |
Naveen29 try this measure
Measure = VAR _sum = DIVIDE ( CALCULATE ( SUM ( t3[Value] ), FILTER ( t3, t3[Category] <> "C" ) ), CALCULATE ( SUM ( t3[Value] ), FILTER ( ALL ( t3 ), t3[Category] = "C" ) ) ) RETURN _sum
4 Replies
- parry2kSuper User
Naveen29 smpa01 measure will work but here is another version of it
% = DIVIDE ( CALCULATE ( SUM ('Table'[Value] ), KEEPFILTERS ( 'Table'[Category] <> "C" ) ), CALCULATE ( SUM ('Table'[Value] ),'Table'[Category] = "C" ) )✨ Follow us on LinkedIn and to our YouTube channel
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
- Naveen29Helper II
Thanks parry2k - This formula is working fine. However , there is another problem over here. My data is like below. When we have break on the data ,this DAX is not working as expected.
Ex:
Value Group 1\Category Name A 1 B 3 C 4 Group2 \Category Name X 2 Y 3 Z 6 Value % Group 1 Total 100% A A/C 25% B B/C 75% Group2 Total 100% X X/Z 33% Y Y/Z 50% Global Total Measure = (A+B+X+Y)/(C+Z) 90%
- parry2kSuper User
Naveen29 the solution was based on your original question, now what you are sharing is totally different from than the original requirement.
The question, what decided to use C or Z what is the logic here? Always provide full details. The solution is based on the requirement.
Read this post to get your answer quickly.
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490