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.
How do I write this in proper DAX?
So far I´ve tested several methods - but I always get an error or an syntax-error
Solved! Go to Solution.
Cleaning up your mismatching parentheses and using a variable, you can write your formula like this:
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF (
ISBLANK ( _KPI ),
BLANK (),
IF (
ISNUMBER ( _KPI ),
_KPI,
"yes"
)
)
This can be further simplified as
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF ( ISBLANK ( _KPI ) || ISNUMBER ( _KPI ), _KPI, "yes" )
However, you're still likely to have a problem since IF cannot output text in some cases and numbers in other cases. It has to output the same data type for both cases. Thus you need to either format your number as text or else use a number instead of "yes". For example, if you want to show your KPI as a percentage with two decimal places, you could use FORMAT to convert the number to text like this:
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF (
ISBLANK ( _KPI ) || ISNUMBER ( _KPI ),
FORMAT ( _KPI, "0.00%" ),
"yes"
)
Thank you very much!
Cleaning up your mismatching parentheses and using a variable, you can write your formula like this:
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF (
ISBLANK ( _KPI ),
BLANK (),
IF (
ISNUMBER ( _KPI ),
_KPI,
"yes"
)
)
This can be further simplified as
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF ( ISBLANK ( _KPI ) || ISNUMBER ( _KPI ), _KPI, "yes" )
However, you're still likely to have a problem since IF cannot output text in some cases and numbers in other cases. It has to output the same data type for both cases. Thus you need to either format your number as text or else use a number instead of "yes". For example, if you want to show your KPI as a percentage with two decimal places, you could use FORMAT to convert the number to text like this:
Test =
VAR _KPI = SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] )
RETURN
IF (
ISBLANK ( _KPI ) || ISNUMBER ( _KPI ),
FORMAT ( _KPI, "0.00%" ),
"yes"
)
Test =
IF (
NOT ISBLANK ( SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] ) ),
IF (
ISNUMBER ( SELECTEDVALUE ( 'FaktKPI'[BewertungKPI] ) ),
SELECTEDVALUE ( FaktKPI[BewertungKPI] ),
"yes"
)
)
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 |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |