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
acg
Resolver I
Resolver I

Create a measure of a measure: when greater than x then 1 else 0

Hi 

 

I have some IDs for which I calculated the average time worked. 

 

Average overtime looks simply like this:

Average Overtime worked=
AVERAGE(timesheet[Weekly_OverTimeHours])
 
How can I create a new measure called 
Indicator= when [Average Overtime worked] > 5 then 1 else 0 ?
 
I know I could use the filter, but I need to have Indicator to create a visual subsequently. 

 

IDAverage Overtime workedIndicator
127381
447640
562361
223350
442371
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @acg ,

The [Margin Type] formula you have created could not be used as a calculated table, it should be a measure or a calculated column.

 

Measure:

Margin Type = 
IF(
    [Average overtime worked] > 5,1,0
)

Calculated column:

Margin Type column =
VAR _avg =
    CALCULATE (
        AVERAGE ( timesheet[Weekly_OverTimeHours] ),
        ALLEXCEPT ( 'timesheet', timesheet[ID] )
    )
RETURN
    IF ( _avg > 5, 1, 0 )

vyingjl_0-1634262517280.png

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@acg , Create a new table like Indicator with values 1,0 and use that as slicer

 

Now create a measure like

calculate([Average Overtime worked]. filter(Values(Table[ID]), [Indicator] = max(Indicator[Indicator])))

 

 

Refer this, if needed

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Does this also work for numeric outcomes? 0/1 needs to be numeric so that it can be used later on for some calculations / visuals, where the indicator needs to be counted. 

Great @amitchandak

 

I see you create the buckets and that is how you create the indicator. 

So I created this as in:

Margin Type =
SWITCH(TRUE(),
[AVG OT Measure] > 5, 1,
[AVG OT Measure] = 5, 1,
[AVG OT Measure] <5, 0)
 
But it says: The expression specified in the query is not a valid table expression.
 
Why would that be? THe indivator 0/1 needs to be numeric, so it can be used later on. 
v-yingjl
Community Support
Community Support

Hi @acg ,

The [Margin Type] formula you have created could not be used as a calculated table, it should be a measure or a calculated column.

 

Measure:

Margin Type = 
IF(
    [Average overtime worked] > 5,1,0
)

Calculated column:

Margin Type column =
VAR _avg =
    CALCULATE (
        AVERAGE ( timesheet[Weekly_OverTimeHours] ),
        ALLEXCEPT ( 'timesheet', timesheet[ID] )
    )
RETURN
    IF ( _avg > 5, 1, 0 )

vyingjl_0-1634262517280.png

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @

PREVIEW
 
 
 

Hi @acg , any luck with the last part of your problem? I am trying to solve the exact same scenario as you were.

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.

Top Solution Authors