March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
Would anyone know if I can apply an if statement to whether or not the calculate function applies a filter? As an example, I'm trying to say,
test =
VAR _Category = SELECTEDVALUE ( 'Table1'[VALUE] )
RETURN
CALCULATE ( SUM ( 'Table2'[TOTAL SAVINGS] ),
IF ( _Category <> "All",
FILTER ( 'Table2', [CATEGORY] = _Category ),
ALLSELECTED ( 'Table2'[CATEGORY] )
)
)
However, I get an error saying "A Function "FILTER" has been used in a True/False experssion that is used as a table filter expression. That is now allowed".
Is there a way to only use filter with a calculate function when a condition is met?
Solved! Go to Solution.
How about this formula below?
test =
VAR _Category = SELECTEDVALUE ( 'Table1'[VALUE] )
RETURN
IF ( _Category <> "All",
SUMX ( FILTER('Table2', 'Table2'[CATEGORY] = _Category), 'Table2'[TOTAL SAVINGS] ),
CALCULATE ( SUM ( 'Table2'[TOTAL SAVINGS] ), ALLSELECTED ( 'Table2'[CATEGORY] ))
)
How about this formula below?
test =
VAR _Category = SELECTEDVALUE ( 'Table1'[VALUE] )
RETURN
IF ( _Category <> "All",
SUMX ( FILTER('Table2', 'Table2'[CATEGORY] = _Category), 'Table2'[TOTAL SAVINGS] ),
CALCULATE ( SUM ( 'Table2'[TOTAL SAVINGS] ), ALLSELECTED ( 'Table2'[CATEGORY] ))
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |