Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
marsclone
Helper IV
Helper IV

Formula Error

I'm getting a error in this formula, the true/false expression must point to one column?

What goes wrong?

 

Ist Year:=VAR Current_Item= IF(HASONEVALUE('Template Ertragslage'[Ertragslage]);VALUES('Template Ertragslage'[Ertragslage]))

RETURN

SWITCH(

TRUE();

Current_Item = "Gesamtleistung"; CALCULATE([Gesamtleistung];DATESYTD(Datumtabel[Date]));

Current_Item= "Rohergebnis"; CALCULATE([Rohergebnis];DATESYTD(Datumtabel[Date]));

Current_Item = "Betrieblicher Aufwand"; CALCULATE([Betrieblicher Aufwand];DATESYTD(Datumtabel[Date]));

Current_Item= "EBITDA"; CALCULATE([EBITDA];DATESYTD(Datumtabel[Date]));

Current_Item = "EBIT"; CALCULATE([EBIT];DATESYTD(Datumtabel[Date]));

Current_Item= "EBT (I)"; CALCULATE([EBT (I)];DATESYTD(Datumtabel[Date]));

Current_Item = "EBT (II)"; CALCULATE([EBT (II)];DATESYTD(Datumtabel[Date]);

Current_Item= "Jahresüberschuss"; CALCULATE([Jahresüberschuss];DATESYTD(Datumtabel[Date]));

Current_Item = "AfA"; CALCULATE([AfA];DATESYTD(Datumtabel[Date]));

Current_Item= "Brutto Cash Flow"; CALCULATE([Brutto Cash Flow];DATESYTD(Datumtabel[Date]));

CALCULATE(

[Ist bedrag];

FILTER('Ertragslage Ist';

'Ertragslage Ist'[Ertragslage] = Current_Item));

DATESYTD(Datumtabel[Date])))

2 REPLIES 2
BA_Pete
Super User
Super User

Hi @marsclone ,

 

I think it's because your Current_Item variable uses the VALUES() function as its output. Per the MS docs:

BA_Pete_0-1673438376662.png

https://learn.microsoft.com/en-us/dax/values-function-dax 

 

I.e, your variable is not outputting a scalar value that can be evaluated as a condition in your SWITCH() function.

 

I would try updating your variable as follows:

VAR Current_Item = SELECTEDVALUE('Template Ertragslage'[Ertragslage])

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @BA_Pete 

Thank you for your answer. The problem that i have, is that i work with power query and power pivot. Selectedvalue doesn't work here.

I have the solution by calculating the values independently.

 

Now i have the measure to calculate the value YTD, but now i become the error:

 

Function 'SWITCH' does not support comparing values of type True/False with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values.

 

Can you see which value i have to format or value so that this measure will work?

Thank you in advance!

 

Ist Year:=

VAR Current_Item= IF(HASONEVALUE('Template Ertragslage'[Ertragslage]);VALUES('Template Ertragslage'[Ertragslage]))

 

RETURN

 

SWITCH(

 

TRUE();

 

Current_Item = "Gesamtleistung"; [Gesamtleistung Year];

 

Current_Item= "Rohergebnis"; [Rohergebnis Year];

 

Current_Item = "Betrieblicher Aufwand"; [Betrieblicher Aufwand Year];

 

Current_Item= "EBITDA"; [EBITDA Year];

 

Current_Item = "EBIT"; [EBIT Year];

 

Current_Item= "EBT (I)"; [EBT (I) Year];

 

Current_Item = "EBT (II)"; [EBT (II) Year];

 

Current_Item= "Jahresüberschuss"; [Jahresüberschuss Year];

 

Current_Item = "AfA"; [AfA Year];

 

Current_Item= "Brutto Cash Flow"; [Brutto Cash Flow Year];

 

CALCULATE(

 

[Ist bedrag Year];

FILTER('Ertragslage Ist';

'Ertragslage Ist'[Ertragslage] = Current_Item));DATESYTD(Datumtabel[Date]))

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.