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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Jackbaz99
Helper I
Helper I

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 )
1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community 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.

vcazhengmsft_0-1645684620025.png

 

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

View solution in original post

2 REPLIES 2
v-cazheng-msft
Community Support
Community 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.

vcazhengmsft_0-1645684620025.png

 

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

Greg_Deckler
Community Champion
Community 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 )


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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