Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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"
)
)