Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello All,
I've come across an issue when attempting to set up a measure to be used in a switch function. Below is my current dax expression:
Value =
the term "VAR" is misleading, unfortunately. It should have been named "CONST" because that's what it is, a constant.
You need to move it inside the CALCULATE statement to be effective
Value =
Calculate(IF(HASONEFILTER(Account[Sub-Account3]),(Sales/Volume),SUMX(VALUES(Account[Sub-Account3]),(Sales/Volume))-[FX],FILTER('Combined P&L','Combined P&L'[Sub-Account3]="Customer Sales"))
Might even need to bring the switch out further.
Hi Ibendlin,
Appreciate the insight. I provided the above details as a skimmed down version of what I am trying to calculate. In the end DAX expression, I am looking to use a SWITCH formula in a waterfall that then looks at multiple accounts. So in the end it would be:
Value =
I already explained why that is the case. You cannot do it this way. Move the SWITCH inside the CALCULATE.
Can you show an example of what you mean by inside? Sorry, just a little confused on that.
instead of SWITCH(...,CALCULATE()) you need to do CALCULATE(SWITCH(...))
Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523
A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
Hi @Anonymous ,
There a syntax error in your formula.
syntax of SWITCH()
SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[, <else>])
You missed <expression> in your code.
Value =
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, thanks for the tip, but I believe the issue is continuing to persist even with the above solution.
Below you can see the comparison of two DAX expressions:
Test Value =
Hi @Anonymous ,
Measures cannot refer to variables defined outside the measure expression, but can refer to functional scope variables defined within the expression.
VAR keyword (DAX) - DAX | Microsoft Docs
Can you share some example data or pbix file without sensitive data and expect result.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
25 | |
18 | |
18 | |
17 | |
16 |
User | Count |
---|---|
29 | |
27 | |
20 | |
15 | |
14 |