Forum Discussion

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

How to have all selected in a switch function

Hi, i have the code below and was wondering how to have it so if "all" were selected on the filter it would show another value?

Really stuck on this one.

Calc 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 )
  • Hi Jackbaz99 ,

     

    You may try this Measure.

    Rework Target =
    
    VAR Table_ =
    
        ADDCOLUMNS (
    
            'Index_Part Information',
    
            "Target",
    
                SWITCH (
    
                    TRUE (),
    
                    "A P" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 1000,
    
                    "AP Jet" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 150,
    
                    "SSO" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 500,
    
                    "LMT" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 500,
    
                    ISBLANK ( SELECTEDVALUE ( 'Index_Part Information'[Additional_Field] ) ), 0
    
                )
    
        )
    
    RETURN
    
        SUMX ( Table_, [Target] )

     

    Then, the result will look like this.

     

    Also, attached the pbix file as reference.

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Jackbaz99 Maybe:

    Calc Rework Target = 
    SWITCH( TRUE(),
    COUNTROWS('Index_Part Information') = COUNTROWS(ALL('Index_Part Information')), 999,
    "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 )
  • v-cazheng-msft's avatar
    v-cazheng-msft
    Icon for Community Support rankCommunity Support

    Hi Jackbaz99 ,

     

    You may try this Measure.

    Rework Target =
    
    VAR Table_ =
    
        ADDCOLUMNS (
    
            'Index_Part Information',
    
            "Target",
    
                SWITCH (
    
                    TRUE (),
    
                    "A P" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 1000,
    
                    "AP Jet" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 150,
    
                    "SSO" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 500,
    
                    "LMT" IN ALLSELECTED ( 'Index_Part Information'[Additional_Field] ), 500,
    
                    ISBLANK ( SELECTEDVALUE ( 'Index_Part Information'[Additional_Field] ) ), 0
    
                )
    
        )
    
    RETURN
    
        SUMX ( Table_, [Target] )

     

    Then, the result will look like this.

     

    Also, attached the pbix file as reference.

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun