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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NABadillo2325
Regular Visitor

Different calculations for same visual

I'm trying to get different results when a shift is selected and when no shifts are selected.

 

If shift = 1 or 2 then "Available" -12

If shift is blank, then "Available" - 24.

 

I was able to get it to work when selecting either 1 or 2 using "Difference = Sum('Combined Ops'[Total Time Available]) - 12"

NABadillo2325_2-1762552134012.png

 

But when niether shift is selected, I need for the difference to be Available - 24.  This is what I'm getting:

NABadillo2325_0-1762551422960.png

How can I get this done?
 
Thank you,

 

2 ACCEPTED SOLUTIONS
Praful_Potphode
Solution Sage
Solution Sage

Hi @NABadillo2325 ,

 

SELECTEDVALUE function is apt for this one.selectedvalue gives blank when nothing is selected  or more than one value is selected.we can customizeour output based on the outcome of selected value

try below measure:

Difference = IF(
ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),
Sum('Combined Ops'[Total Time Available])-24,
Sum('Combined Ops'[Total Time Available])-12
)

Please give kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

View solution in original post

Hi @NABadillo2325 ,

 

when you have two conditions ,USE IF expression.

when you have more than two conditions,use SWITCH expression.

something like below should work.do the ordering of  conditions as per your requirements.

Difference = SWITCH(TRUE(),
ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])),Sum('Combined Ops'[Total Time Available])-120, //condition 1
ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-24,//condition 2
Sum('Combined Ops'[Total Time Available])-12 //else part
)

 

Thanks and Regards,

Praful

View solution in original post

9 REPLIES 9
Praful_Potphode
Solution Sage
Solution Sage

Hi @NABadillo2325 ,

 

SELECTEDVALUE function is apt for this one.selectedvalue gives blank when nothing is selected  or more than one value is selected.we can customizeour output based on the outcome of selected value

try below measure:

Difference = IF(
ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),
Sum('Combined Ops'[Total Time Available])-24,
Sum('Combined Ops'[Total Time Available])-12
)

Please give kudos or mark it as solution once confirmed.

 

Thanks and Regards,

Praful

I have a new request.  I need a calculation that incorporates the above solution but can aslo process the below:

Difference6 = IF(
ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])),
SUM('Combined Ops'[Automatic])-120
)
Can this be done?



Hi @NABadillo2325 ,

 

when you have two conditions ,USE IF expression.

when you have more than two conditions,use SWITCH expression.

something like below should work.do the ordering of  conditions as per your requirements.

Difference = SWITCH(TRUE(),
ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])),Sum('Combined Ops'[Total Time Available])-120, //condition 1
ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-24,//condition 2
Sum('Combined Ops'[Total Time Available])-12 //else part
)

 

Thanks and Regards,

Praful

@Praful_Potphode,

 

I don't mean to nickel and dime this formula, but I also need a requirement that allows for the following:

 

If Machine is blank and either shift is selected, then Total Time - 60.

 

Just to be clear,  These are the requirements for the formula.
1 - Machine blank and shift blank = total -120
2 - Machine blank and shift selected = total -60
3 - Machine select and shift blank = Total -24
4 - Machine selected and shift selected = total -12

 

I tried modifying your formula, but have been unsuccesful.

 

Thank you in advance for your help.

@NABadillo2325 

please try below:

Difference = SWITCH(TRUE(),
ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])) && ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-120, //condition 1
ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])) && not ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-60, //condition 2

not ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])) && ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-24, //condition 3
not ISBLANK(SELECTEDVALUE('Combined Ops'[Machine Name])) && not ISBLANK(SELECTEDVALUE('Combined Ops'[Shift])),Sum('Combined Ops'[Total Time Available])-12, //condition 4
)

Please give kudos if it works.

 

Thanks and Regards,
Praful

@Praful_Potphode ,

 

I'm getting the following error:

NABadillo2325_0-1763388809966.png

Thank you,

 

This works great.  Thank you so much.

 

Thank you so much.  That worked perfect.

samratpbi
Super User
Super User

Hi @NABadillo2325 , I dont have your dataset, hence cant calculate Sum('Combined Ops'[Total Time Available]) , however if you use the below measure, it should resolve your problem.

 

I created a measure like below:

Difference =
IF(ISFILTERED(AllSeasons[SessionTitle]),
20 - 12,
20 - 24
)
here replace AllSeasons[SessionTitle] with your Shift column and 20 with your SUM calculation. Idea is when Shift column is filtered when -12, otherwise -24.
below is output:
when nothing selected
samratpbi_0-1762554668489.png

when a value selected:

samratpbi_1-1762554705532.png

Hope this helps to resolve your problem.

If it does, then mark it as solution.

 

Thanks - Samrat

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors