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
Pseifert
Frequent Visitor

Group By for calculated column

Hello,
 
I am trying to select the correct cycle speed with dax based on the MIN recipe #. My current measure below, however, does not account for an ITEM that has multiple resources. How can I adjust my calculated column to account for the resource. I can not figure out how to or if Group By is the correct function here but it seems you can not use group by and calculate. Right now, my measure looks at this first 0 and has assigned 0 for the current cycle. See picture below for expected results.
 
 
CurrentCycle =
Calculate(
SELECTEDVALUE(V_SAP_NTEC_CI_CYCLES01[CYCLE_SPEED]),
Filter(all(V_SAP_NTEC_CI_CYCLES01),(V_SAP_NTEC_CI_CYCLES01[RECIPE]=Min(V_SAP_NTEC_CI_CYCLES01[RECIPE])))
)Capture.JPG
1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@Pseifert 

 

You may use the following DAX to add a calculated column.

 

Column =
MAXX (
    TOPN (
        1,
        FILTER (
            V_SAP_NTEC_CI_CYCLES01,
            V_SAP_NTEC_CI_CYCLES01[ITEM_ID] = EARLIER ( V_SAP_NTEC_CI_CYCLES01[ITEM_ID] )
                && V_SAP_NTEC_CI_CYCLES01[RESOURCE] = EARLIER ( V_SAP_NTEC_CI_CYCLES01[RESOURCE] )
        ),
        V_SAP_NTEC_CI_CYCLES01[RECIPE], ASC
    ),
    V_SAP_NTEC_CI_CYCLES01[CYCLE_SPEED]
)

 

 

Community Support Team _ Sam Zha
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

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Pseifert 

 

You may use the following DAX to add a calculated column.

 

Column =
MAXX (
    TOPN (
        1,
        FILTER (
            V_SAP_NTEC_CI_CYCLES01,
            V_SAP_NTEC_CI_CYCLES01[ITEM_ID] = EARLIER ( V_SAP_NTEC_CI_CYCLES01[ITEM_ID] )
                && V_SAP_NTEC_CI_CYCLES01[RESOURCE] = EARLIER ( V_SAP_NTEC_CI_CYCLES01[RESOURCE] )
        ),
        V_SAP_NTEC_CI_CYCLES01[RECIPE], ASC
    ),
    V_SAP_NTEC_CI_CYCLES01[CYCLE_SPEED]
)

 

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @Pseifert,

 

Is CurrentCycle a calculated column in your table or is it a measure? You refer to it as both.

 

Thanks!

Sorry, I have it as a measure now, I am unsure which would be ideal to be honest.

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.