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

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.

Reply
Jackbaz99
Helper I
Helper I

Wrap a Switch statement into Calculate possible?

Hi,

 

Is it possible to wrap the following:

 

Rework Target = 
SWITCH( TRUE(),
SELECTEDVALUE('Index_Part Information'[Additional_Field_2]) = "A P", 1000 ,
SELECTEDVALUE('Index_Part Information'[Additional_Field_2]) = "AP Jet", 150 ,
SELECTEDVALUE('Index_Part Information'[Additional_Field_2]) = "SSO", 500 ,
SELECTEDVALUE('Index_Part Information'[Additional_Field_2]) = "LMT", 500,
SELECTEDVALUE('Index_Part Information'[Additional_Field_2]) = "", 500 )

 

into a calculated/filtered measure with the following filter 

 

FILTER('Date Table','Date Table'[Date] <= TODAY())

 


Thanks

3 REPLIES 3
Jackbaz99
Helper I
Helper I

@amitchandak 

 

I think the issue lies with the other values on the graph whic is as below 

 

 

Rework Cost = SUMX(FILTER('Date Table','Date Table'[Date] <= TODAY()),CALCULATE(SUM('Sub_NCR'[CST_GT_Rework])) + 0 )

 

 

This is giving me row context so i can show values as 0 (as we discussed earlier) but now i have the same problem when doing the rework target line - i can get the measure to work, however it now shows the all the dates even if ive filtered to last 12 calendar months

amitchandak
Super User
Super User

@Jackbaz99 , Create measure like

Rework Target =
SWITCH( TRUE(),
"A P" in allselected('Index_Part Information'[Additional_Field_2]) , 1000 ,
"AP Jet" in allselected('Index_Part Information'[Additional_Field_2]) , 150 ,
"SSO" in allselected('Index_Part Information'[Additional_Field_2]) , 500 ,
"LMT" in allselected('Index_Part Information'[Additional_Field_2]) , 500,
isblank(selectedvalue('Index_Part Information'[Additional_Field_2])) , 500 )

@amitchandak Hi, this does work - however i still need filtered between the dates. 

The rework target line stays filtered to all dates regardless of what my date filter says on the page which is the last 12 calendar months.

 

How can i do this please?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.