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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
v_mark
Helper V
Helper V

Simple Switch Statement GAP in Values

I was trying to satisfy a requirement based on these parameters

 

Count of Transactions

less than 24 Hrs,

More than 72 Hrs and

More than 120 Hours

 

I created a calculated column Hours Difference by using datediff

Hours = DATEDIFF('Sample Data'[CreatedDateTime],NOW(),HOUR)

 

and create a tagging 

SLAs = SWITCH(TRUE(),
'Sample Data'[Hours] <= 24 , " Less than 24 Hrs ",
'Sample Data'[Hours] >= 72 , " More Than 72 Hrs ",
'Sample Data'[Hours] >= 120, " More Than 120 Hrs",
BLANK())


Which returns like 

v_mark_0-1635533081903.png

My problem with this requirement is there is a gap there are some transactions that occur 25+ hours up to 71 hours. 
which is not covered in the requirement that was given.

Any chance of Specifying those in the actual measure? I was hoping to see those 120+ as well 
Workarounds are highly appreciated. TIA!


Sharing the sample PBIX  

1 ACCEPTED SOLUTION
mwegener
Most Valuable Professional
Most Valuable Professional

Hi @v_mark ,

 

try this

 

SLAs = SWITCH(TRUE(),
'Sample Data'[Hours] <= 24 , " Less than 24 Hrs ",
'Sample Data'[Hours] >= 120, " More Than 120 Hrs",
'Sample Data'[Hours] >= 72 , " More Than  72 Hrs ",
'Sample Data'[Hours] >= 25 , " More Than  25 Hrs ", 
BLANK())
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @v_mark ,

Here are the steps you can follow:

1. Create calculated column.

 

SLAs =
SWITCH(TRUE(),
'Sample Data'[Hours] <= 24 ," Less than 24 Hrs ",
'Sample Data'[Hours] >= 72&&'Sample Data'[Hours]<120 ," More Than 72 Hrs ",
'Sample Data'[Hours] >= 120," More Than 120 Hrs",
BLANK())

 

2. If you don’t want to display blank data, you can turn off "Show items with no data".

vyangliumsft_0-1635835539122.png

3. Result:

vyangliumsft_1-1635835539122.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

mwegener
Most Valuable Professional
Most Valuable Professional

Hi @v_mark ,

 

try this

 

SLAs = SWITCH(TRUE(),
'Sample Data'[Hours] <= 24 , " Less than 24 Hrs ",
'Sample Data'[Hours] >= 120, " More Than 120 Hrs",
'Sample Data'[Hours] >= 72 , " More Than  72 Hrs ",
'Sample Data'[Hours] >= 25 , " More Than  25 Hrs ", 
BLANK())
Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors