Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a complex DAX statment to calculate a column (yes, I know, don't get me started).
It works.
It has several calculations, all organised nicely using VAR statements.
The issue is as follows:
I want the code to return a specific value if a certain condition is met in the 1st go, and then not run through the extra caculations.
So, instead of:
0.1 My Col =
_VAR _V1 = calc
_VAR _V2 = calc
_VAR _V3 = calc
VAR _RET = IF (Table[column], 8, _v1 + v2 +v3)
RETURN _RET
Which means I would run all 3 calcs,
I want to write something like:
0.1 My Col =
IF (Table[column],
RETURN 8,
_VAR _V1 = calc
_VAR _V2 = calc
_VAR _V3 = calc
RETURN _v1 + v2 +v3
)
I don't get it to work.
Is it even possible? Thanks!
Solved! Go to Solution.
Hi @Hila_DG_TMX
This should be the correct syntax:
0.1 My Col =
IF (
Table[column],
8,
VAR _V1 = calc
VAR _V2 = calc
VAR _V3 = calc
RETURN
_V1 + _V2 + _V3
)
The three variables should only be evaluated when the condition within IF is false.
Does this work as expected for you?
Hi @Hila_DG_TMX
This should be the correct syntax:
0.1 My Col =
IF (
Table[column],
8,
VAR _V1 = calc
VAR _V2 = calc
VAR _V3 = calc
RETURN
_V1 + _V2 + _V3
)
The three variables should only be evaluated when the condition within IF is false.
Does this work as expected for you?
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |