Forum Discussion
DAX Calculate IF OR Statement
- Anonymous10 years ago
CALCULATE(
SUM(Table[Column X]),
FILTER(
Table,
Table[Column A] = "Renewal" ||
Table[Column B] = "Needs Alignment")
)
CALCULATE(
SUM(Table[Column X]),
FILTER(
Table,
Table[Column A] = "Renewal" ||
Table[Column B] = "Needs Alignment")
)
That was so much easier than I was trying to make it, didn't even know about the Filter function, this worked perfectly, Thank you!
- Anonymous10 years agoNot applicable
CALCULATE(<expression>, FILTER( <table>, <table[column] = condition>)) is probably the most generally useful pattern to learn in DAX. The vast majority of measures I write either follow this pattern or contain a part that follows this pattern.
- dtartaglia9 years agoResolver I
Hi KHorseman,
The CALCULATE/FILTER syntax you supplied really helped me with DAX statements in general.
Thanks,
Dan
- Willborn9 years agoAdvocate III
Hi there
Thanks for this solution - it guided me a step further with a filter challange :smileyhappy:
i'm currently struggling with adding multiple filters:
POS Attribut Value 1 A 10 2 B 200 3 C 3000 4 D 40000 5 E 500000 6 A 10 7 B 200 8 C 3000 9 D 40000 10 E 500000
I summed the total of all SAP[Value] where [Attribute] is "A":
Total_AB = CALCULATE(SUM(SAP[Value]); FILTER( SAP; SAP[Attribut] = "B") )
But I need to Sum the total of all SAP[Value] where [Attribute] is "A", "B" and "E" - but the filter functions allow only 2 statements. Does someone has an idea how to solve this with DAX?
Thx! Patrick