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
itchyeyeballs
Impactful Individual
Impactful Individual

Measure for max by group

Hi All,

 

I'm looking to turn this calculated column into a measure:

XtPoints_Scaled = 
VAR Xi = Core_Data_All[XTPOINTS]
VAR MnX = CALCULATE(MIN(Core_Data_All[XTPOINTS]),FILTER(Core_Data_All,Core_Data_All[Year]=EARLIER(Core_Data_All[Year])))
VAR MxX = CALCULATE(MAX(Core_Data_All[XTPOINTS]),FILTER(Core_Data_All,Core_Data_All[Year]=EARLIER(Core_Data_All[Year])))
RETURN DIVIDE(Xi-MnX , MxX - MnX)

I'm struggling to find a way to dynamically calculate the max and min values for a group using the current row context, for example, min xtpoints where year = 2017.


The above syntax only works as a calculated column which means my filters don't get applied etc.

 

Is there a way to achieve this? It seems simple!

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @itchyeyeballs ,

Maybe you could try this:

Measure =
DIVIDE (
    MAX ( Core_Data_All[XTPOINTS] )
        - CALCULATE (
            MIN ( Core_Data_All[XTPOINTS] ),
            ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
        ),
    CALCULATE (
        MAX ( Core_Data_All[XTPOINTS] ),
        ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
    )
        - CALCULATE (
            MIN ( Core_Data_All[XTPOINTS] ),
            ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
        )
)

measure222.PNG

Best Regards,
Icey

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
Icey
Community Support
Community Support

Hi @itchyeyeballs ,

 

Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
itchyeyeballs
Impactful Individual
Impactful Individual

Hi

 

Thank you for the response and apologies for not responding earlier.

 

It didn't fix the issue as I needed to retain other filters being applied to get the correct subset of data, I guess I could have expanded your solution but I ended up doing the calculations during the data prep process, made the model very slow to update but gets there in the end.

 

Thank you

 

 

Icey
Community Support
Community Support

Hi @itchyeyeballs ,

Maybe you could try this:

Measure =
DIVIDE (
    MAX ( Core_Data_All[XTPOINTS] )
        - CALCULATE (
            MIN ( Core_Data_All[XTPOINTS] ),
            ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
        ),
    CALCULATE (
        MAX ( Core_Data_All[XTPOINTS] ),
        ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
    )
        - CALCULATE (
            MIN ( Core_Data_All[XTPOINTS] ),
            ALLEXCEPT ( Core_Data_All, Core_Data_All[Year] )
        )
)

measure222.PNG

Best Regards,
Icey

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

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.