Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have data like this
Id | Amount | Flag |
1 | 10 | Yes |
2 | 20 | No |
3 | 30 | Yes |
4 | 40 | No |
5 | 50 | Yes |
Total | 150 |
Amount and Flag are measures. I want to have other columns ValueswithYES, ValueswithNO and totals like this
Id | Amount | Flag | ValueswithYES | ValueswithNO | |
1 | 10 | Yes | 10 | ||
2 | 20 | No | 20 | ||
3 | 30 | Yes | 30 | ||
4 | 40 | No | 40 | ||
5 | 50 | Yes | 50 | ||
Total | 150 | Yes | 90 | 60 |
I have used measures like this ValueswithYES = if(Flag="Yes",[Amount]), getting the values right but the total I am getting as 150 which is incorrect. How do I achieve this?
Solved! Go to Solution.
Values w/ YES = SUMX(VALUES(DATA[ID]),IF([Flag]="YES",[Amount]))
Values w/ NO = SUMX(VALUES(DATA[ID]),IF([Flag]="NO",[Amount]))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Values w/ YES = SUMX(VALUES(DATA[ID]),IF([Flag]="YES",[Amount]))
Values w/ NO = SUMX(VALUES(DATA[ID]),IF([Flag]="NO",[Amount]))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
That didn't work. My Flag is also measure.
Getting this error A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
What is the measure for 'Flag'?
Proud to be a Super User!
@bml123 - try as:
ValueswithYes Measure =
CALCULATE(
[Amount Measure],
TableName[Flag] = "Yes"
)
ValueswithYes Measure =
CALCULATE(
[Amount Measure],
TableName[Flag] = "No"
)
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
99 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |