Forum Discussion

Jackbaz99's avatar
Jackbaz99
Icon for Helper I rankHelper I
4 years ago

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

  • 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 )

    • Jackbaz99's avatar
      Jackbaz99
      Icon for Helper I rankHelper I

      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?

  • 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