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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
JenAbe
Frequent Visitor

Running MAXIMUM of measure result in a period.

I have a scenario where I need to determine the MAX value of a calculated measure within a period for a specific entity (ie by date and id). 

 

I have been able to use DAX to get the MAX value by period by id overall BUT as the number fluxtuates during the time period being reported I want this measure to always reflect the maximum up until that point. To illustrate:

 

JenAbe_0-1689628904546.png

 

Note how the max always reflect the maximum value of all values between it and the start date (each id has a start date associated with it in this case April 21

 

The DAX I came up with which gives me an overall MAX reliably looks like this:

 

VAR a = CALCULATETABLE(
SUMMARIZE(
Calendar,
Calendar[Month-Year],
"# Items", [# Items Measure]
), NOT ISBLANK( OtherTable[Id] )
)

 

VAR b = CALCULATE( MAXX( a, [# Items] ),values(OtherTable[Id]) )


RETURN b

 

Any ideas? I am able to do this in SQL and in EXCEL. Can probably do it in M - but I really want this to be a calculated measure in DAX if possible. I mean, it should be possible?

 

Help!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, 

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1689649913707.png

 

 

Jihwan_Kim_0-1689649889008.png

 

 

Max of value measure: =
IF (
    HASONEVALUE ( 'ID'[ID] ),
    MAXX (
        WINDOW (
            1,
            ABS,
            0,
            REL,
            SUMMARIZE (
                ALL ( Data ),
                'Calendar'[Month-Year sort],
                'Calendar'[Month-Year],
                'ID'[ID]
            ),
            ORDERBY ( 'Calendar'[Month-Year sort], ASC ),
            ,
            PARTITIONBY ( 'ID'[ID] )
        ),
        CALCULATE ( SUM ( Data[Count of Value] ) )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
JenAbe
Frequent Visitor

Thank you so much, this solution worked with a little tweaking to the metric being MAXX'd - had some minor issues but otherwise good to go!

Jihwan_Kim
Super User
Super User

Hi, 

I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_1-1689649913707.png

 

 

Jihwan_Kim_0-1689649889008.png

 

 

Max of value measure: =
IF (
    HASONEVALUE ( 'ID'[ID] ),
    MAXX (
        WINDOW (
            1,
            ABS,
            0,
            REL,
            SUMMARIZE (
                ALL ( Data ),
                'Calendar'[Month-Year sort],
                'Calendar'[Month-Year],
                'ID'[ID]
            ),
            ORDERBY ( 'Calendar'[Month-Year sort], ASC ),
            ,
            PARTITIONBY ( 'ID'[ID] )
        ),
        CALCULATE ( SUM ( Data[Count of Value] ) )
    )
)

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hey, the solution you gave me works but I have a small issue. My max measure seems to randomly return blanks for no apparent reason:

 

JenAbe_0-1689799057579.png

IF (
HASONEVALUE ( 'Table'[Id] ),
MAXX(
WINDOW(
1,
ABS,
0,
REL,
SUMMARIZE(
ALL( Table ),
Calendar[Sort Month Year],
Calendar[Month Year],
'Table'[Id]
),
ORDERBY( Calendar[Sort Month Year], ASC ),
,
PARTITIONBY( 'Table'[Id] )
),
CALCULATE( [Measure Value Logic])
)
)

 

There is a value returned for the measure being 'maxed' but it doesn't want to display that value in some cases. I thought it may be HAS ONE VALUE -but it does have one value that can't be right...

 

Any ideas ( I realize this is a bit obscure) 

Hi,

Please share your sample pbix file's link, and then I can try to look into it.

Thank you.


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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.

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.