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
chudson002
Frequent Visitor

SWITCH FUNCTION WORKS FOR SOME CATEGORIES, BUT NOT ALL

Good Evening Community,

Switch function does not work for all categories.  What am I missing? Should I use the Range column? Any assistance is greatly appreciated.  Please see the below:

KPI = SWITCH(

TRUE(),
'Count'[Threshold] = "ANY" && 'Count'[Average] > 60, "0",
'Count'[Threshold] = "<$50M" && 'Count'[Average] > 135, "0",
'Count'[Threshold] = ">$50M" && 'Count'[Average] > 240, "0",
'Count'[Threshold] = "<$250,000" && 'Count'[Average] > 30, "0",
'Count'[Threshold] = ">$250k but NTE $7M" && 'Count''[Average] > 45, "0",
'Count''[Threshold] = ">$7M" && 'Count'[Average] > 60, "0",
'Count'[Threshold] = "<$250k" && 'Count'[Average] > 35, "0",
'Count'[Threshold] = ">$250k but NTE $7M" && 'Count'[Average] > 60, "0",
'Count'[Threshold] = ">$7M" && 'Count'[Average] > 120, "0",
"1")

 Averages of (74, 20 & 31) KPI s/b "1"... 

    Category                     Range           Average       KPI

chudson002_1-1656991295571.png

 

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @chudson002 ,

 

Try using SUM('Count'[Average]) instead.
IF it's a measure, use SUMX('Count','Count'[Average]).

Also try IF() function.

KPI =
IF (
    ( 'Count'[Threshold] = "ANY"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = "<$50M"
        && 'Count'[Average] > 135 )
        || ( 'Count'[Threshold] = ">$50M"
        && 'Count'[Average] > 240 )
        || ( 'Count'[Threshold] = "<$250,000"
        && 'Count'[Average] > 30 )
        || ( 'Count'[Threshold] = ">$250k but NTE $7M"
        && 'Count'[Average] > 45 )
        || ( 'Count'[Threshold] = ">$7M"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = "<$250k"
        && 'Count'[Average] > 35 )
        || ( 'Count'[Threshold] = ">$250k but NTE $7M"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = ">$7M"
        && 'Count'[Average] > 120 ),
    "0",
    "1"
)

 If it still doesn't work, please share the pbix.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @chudson002 ,

 

Try using SUM('Count'[Average]) instead.
IF it's a measure, use SUMX('Count','Count'[Average]).

Also try IF() function.

KPI =
IF (
    ( 'Count'[Threshold] = "ANY"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = "<$50M"
        && 'Count'[Average] > 135 )
        || ( 'Count'[Threshold] = ">$50M"
        && 'Count'[Average] > 240 )
        || ( 'Count'[Threshold] = "<$250,000"
        && 'Count'[Average] > 30 )
        || ( 'Count'[Threshold] = ">$250k but NTE $7M"
        && 'Count'[Average] > 45 )
        || ( 'Count'[Threshold] = ">$7M"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = "<$250k"
        && 'Count'[Average] > 35 )
        || ( 'Count'[Threshold] = ">$250k but NTE $7M"
        && 'Count'[Average] > 60 )
        || ( 'Count'[Threshold] = ">$7M"
        && 'Count'[Average] > 120 ),
    "0",
    "1"
)

 If it still doesn't work, please share the pbix.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@chudson002 , Make sure you handle overlapping ranges

 

, please check in bold

 

KPI = SWITCH(
TRUE(),
'Count'[Threshold] = "ANY" && 'Count'[Average] > 60, "0",
'Count'[Threshold] = "<$50M" && 'Count'[Average] > 135, "0",
'Count'[Threshold] = ">$50M" && 'Count'[Average] > 240, "0",
'Count'[Threshold] = "<$250,000" && 'Count'[Average] > 30 && 'Count'[Average] < 60, "0",
'Count'[Threshold] = ">$250k but NTE $7M" && 'Count'[Average] > 45, "0",
'Count'[Threshold] = ">$7M" && 'Count'[Average] > 60 && 'Count'[Average] < 120, "0",
'Count'[Threshold] = "<$250k" && 'Count'[Average] > 35, "0",
'Count'[Threshold] = ">$250k but NTE $7M" && 'Count'[Average] > 60, "0",
'Count'[Threshold] = ">$7M" && 'Count'[Average] > 120, "0",
"1")

Good Day,

Revised per recommendation, indicators did not update.

Any suggestions?

 

V/R

chudson002

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.