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
hanswittoeck
Helper II
Helper II

problem with SWITCH function

hanswittoeck_0-1753455508025.png

can somebody explain why we see here '+ 1 day'? the value is cleary above 10080, so I expect to see '+1 week'

 

3 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @hanswittoeck ,

 

Is this a metric or a calculated column? Taking into account the code you show I assume this is a calculated column so the values are calculated for each row of the table, I assume that each notification nº can have more than one line in your table, with small values.

 

Create new measure and use the same syntax but instead of:

 

'Operations F_PM_Notification_Details'[Duration in Minutes]

 

use 
SUM('Operations F_PM_Notification_Details'[Duration in Minutes])

 

So your syntax will be:

Groups =
SWITCH (
      TRUE(),
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 10080, "+1 Week", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 1440, "+1 day", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 15, "Max 15m", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 60, "Max 1h"
  )

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

lbendlin
Super User
Super User

Do you want to categorize individual transactions, or the aggregates?  For aggregates you need to materialize the result first before comparing it.

View solution in original post

HarishKM
Memorable Member
Memorable Member

@hanswittoeck Hey,
I will below to use below measure.

 

Groups = SWITCH ( TRUE(),
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 10080, "+1 Week",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 1440, "+1 Day",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) > 60, "Max 1h",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 60, "Less than 1h",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 15, "Max 15m",
"Regular")

 

 


Thanks

Harish KM

If above step's solved your problem. Kudos will be highly apprieciated. Accept this as solution as well

View solution in original post

4 REPLIES 4
HarishKM
Memorable Member
Memorable Member

@hanswittoeck Hey,
I will below to use below measure.

 

Groups = SWITCH ( TRUE(),
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 10080, "+1 Week",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 1440, "+1 Day",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) > 60, "Max 1h",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 60, "Less than 1h",
SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 15, "Max 15m",
"Regular")

 

 


Thanks

Harish KM

If above step's solved your problem. Kudos will be highly apprieciated. Accept this as solution as well

the problem was in my agregation. if a same notification has multiple occurances, it shows the sum. In reality it should show only 1 value, not the sum.

lbendlin
Super User
Super User

Do you want to categorize individual transactions, or the aggregates?  For aggregates you need to materialize the result first before comparing it.

MFelix
Super User
Super User

Hi @hanswittoeck ,

 

Is this a metric or a calculated column? Taking into account the code you show I assume this is a calculated column so the values are calculated for each row of the table, I assume that each notification nº can have more than one line in your table, with small values.

 

Create new measure and use the same syntax but instead of:

 

'Operations F_PM_Notification_Details'[Duration in Minutes]

 

use 
SUM('Operations F_PM_Notification_Details'[Duration in Minutes])

 

So your syntax will be:

Groups =
SWITCH (
      TRUE(),
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 10080, "+1 Week", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) >= 1440, "+1 day", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 15, "Max 15m", 
      SUM('Operations F_PM_Notification_Details'[Duration in Minutes]) <= 60, "Max 1h"
  )

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.