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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JamesBurke
Helper III
Helper III

Switch function

Hi All , 

 

Using the swtich function to swtich measure based on what building is selected but when blank i would like it to be another Measure.

 

cc 34 = 
SWITCH(
    MAX('Emporia Devices'[Wawrick Device Name (groups)]),
   "N1 Kings High School",[Total Consumption],
    "Bridge Theatre",[Total Consumption],
    "Warwick Sport Centre",[Total Consumption],
    "Cheshire science",[Total Consumption],
    "Gibson Building",[Total Consumption],
    "Junior Music Block",[Total Consumption],
    "Macefield Building",[Total Consumption],
    "Main School",ROUND([Main School - Art & Design],2),
    "N3 Prep School Music",[Total Consumption],
    "Kings Pavillion",[Total Consumption],
    "Thornton Building",[Total Consumption],
    "Warwick Hall",[Total Consumption],
    "Bridge Sports Centre",[Total Consumption],
    "Estates",[Total Consumption],
    "Junior School",[Total Consumption],
    "Nursery",[Total Consumption],
    "Prep School",ROUND([Prep - BSP 1 & Nursery],2),
    "Sixth Form",[Total Consumption],
    "Art and Design",ROUND([Art Design - MFL , Humanities & Thorton],2),
    "N2 Bridge Extension" , [Total Consumption],
    "Junior Assembly",[Total Consumption],
    "kitchens",[Total Consumption],
    "Humanities",[Total Consumption],
    "MFL" , [Total Consumption]

)

 

however When none is selected it takes the max of the group which is the max of the group alphabetically so when no building is selected currently it goes to warwick sports centre.

 

I want to to have it so when no building is selected it is blank and would be something similar to "blank", [New Total Consumption]

 

Thanks , James.

1 ACCEPTED SOLUTION
ajohnso2
Super User
Super User

Since you have not attached a sample pbix. Please try..

 

edit: Re-read requirement, please try...

 

 

cc 34 =
VAR _Selected = SELECTEDVALUE('Emporia Devices'[Wawrick Device Name (groups)], "") // This should be a value that doesnt exist in [Wawrick Device Name (groups)] "" should be sufficient, effectively setting to a non value producing BLANK results
SWITCH(
    _Selected,
   "N1 Kings High School",[Total Consumption],
    "Bridge Theatre",[Total Consumption],
    "Warwick Sport Centre",[Total Consumption],
    "Cheshire science",[Total Consumption],
    "Gibson Building",[Total Consumption],
    "Junior Music Block",[Total Consumption],
    "Macefield Building",[Total Consumption],
    "Main School",ROUND([Main School - Art & Design],2),
    "N3 Prep School Music",[Total Consumption],
    "Kings Pavillion",[Total Consumption],
    "Thornton Building",[Total Consumption],
    "Warwick Hall",[Total Consumption],
    "Bridge Sports Centre",[Total Consumption],
    "Estates",[Total Consumption],
    "Junior School",[Total Consumption],
    "Nursery",[Total Consumption],
    "Prep School",ROUND([Prep - BSP 1 & Nursery],2),
    "Sixth Form",[Total Consumption],
    "Art and Design",ROUND([Art Design - MFL , Humanities & Thorton],2),
    "N2 Bridge Extension" , [Total Consumption],
    "Junior Assembly",[Total Consumption],
    "kitchens",[Total Consumption],
    "Humanities",[Total Consumption],
    "MFL" , [Total Consumption],
"", [New Total Consumption]

)

 

 

View solution in original post

3 REPLIES 3
MNedix
Super User
Super User

Heya,

The last argument in the SWITCH function is the optional ELSE. Have you tried just adding the [New Total Comsumption] at the end?

MNedix_0-1729784033010.png

 



If the post helped then please give it a Kudos and mark it as the solution so others can see it.
Cheers,

Hi @MNedix , 

 

when no building is selected is defualts to warwick sports centre which uses total consumption , i di try adding it at the end for "else" but this did not work as it takes warwick sports centre as the max. 

 

Hope this makes sense

ajohnso2
Super User
Super User

Since you have not attached a sample pbix. Please try..

 

edit: Re-read requirement, please try...

 

 

cc 34 =
VAR _Selected = SELECTEDVALUE('Emporia Devices'[Wawrick Device Name (groups)], "") // This should be a value that doesnt exist in [Wawrick Device Name (groups)] "" should be sufficient, effectively setting to a non value producing BLANK results
SWITCH(
    _Selected,
   "N1 Kings High School",[Total Consumption],
    "Bridge Theatre",[Total Consumption],
    "Warwick Sport Centre",[Total Consumption],
    "Cheshire science",[Total Consumption],
    "Gibson Building",[Total Consumption],
    "Junior Music Block",[Total Consumption],
    "Macefield Building",[Total Consumption],
    "Main School",ROUND([Main School - Art & Design],2),
    "N3 Prep School Music",[Total Consumption],
    "Kings Pavillion",[Total Consumption],
    "Thornton Building",[Total Consumption],
    "Warwick Hall",[Total Consumption],
    "Bridge Sports Centre",[Total Consumption],
    "Estates",[Total Consumption],
    "Junior School",[Total Consumption],
    "Nursery",[Total Consumption],
    "Prep School",ROUND([Prep - BSP 1 & Nursery],2),
    "Sixth Form",[Total Consumption],
    "Art and Design",ROUND([Art Design - MFL , Humanities & Thorton],2),
    "N2 Bridge Extension" , [Total Consumption],
    "Junior Assembly",[Total Consumption],
    "kitchens",[Total Consumption],
    "Humanities",[Total Consumption],
    "MFL" , [Total Consumption],
"", [New Total Consumption]

)

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.