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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Measure showing MIN and MAX of another measure, across a date range

I'm trying to create a measure which I can use in visuals to label the highest and lowest values of another measure across a filtered date range, ultimately like this: 

charliedata_1-1607295050319.png

 

 

I'm unable to get the right DAX to do this, and I've tried various approaches using MINX / MAXX with ALLSELECTED or SUMMARIZE and ADDCOLUMNS (because SUMMARIZECOLUMNS didn't work)

Below is the kind of result I'd like the measure to deliver (included Sum as I might use that too, and I assume I'd just use a SUM / SUMX):

 

charliedata_0-1607294309318.png

(I know I'll need to filter the results so that I don't have the min / max in every row)

 

For the selected date range and only for the dates that have a non-blank value for the underlying measure, I'd like to calculate the min and max values across the range

I use date hierarchies, so I need to factor the context filter effect of the additional columns. In this case, I've shown that the week of November 30 actually spans two calendar months

Based on previous answers to similar questions, this is the closest I got but it returns the wrong result, in red above

 

charliedata_2-1607295433153.png

 

I assume I need to remove filters in some way using ALLSELECTED, so I've tried using it (inside CALCULATE) in the table and in the MAXX steps but none of these give the right result

Any help much appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I'll write it up in an article, maybe here and on Medium

 

Basically I used the same measures but added some SWITCH logic to avoid wrong results

View solution in original post

9 REPLIES 9
mahoneypat
Microsoft Employee
Microsoft Employee

Glad you got it working.  What was the final measure that worked?

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

I'll write it up in an article, maybe here and on Medium

 

Basically I used the same measures but added some SWITCH logic to avoid wrong results

Anonymous
Not applicable

Hi @Anonymous ,

I'm glad to hear that your problem has been solved. And thanks for sharing. Could you please mark your post as Answered? It will help others in the community find the solution easily if they face the same problem with you. Thank you.

Best Regards

mahoneypat
Microsoft Employee
Microsoft Employee

Just to clarify, are all of the columns in the visual (not the measures) included in the ALLSELECTED?  If not, please add whatever one is missing.  Also, if you share a link to the pbix (or a mock up of same issue), I can troubleshoot directly.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi @mahoneypat  - thanks again for the help. I got it to work as desired in the end so didn't upload anything, but I appreciate the offer!

CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , I think you're just one inch away from you goal; you might want to try

Max of measure = MAXX( ALLSELECTED( 'Calendar'[Date] ), [measure] )

Min of measure = MINX( ALLSELECTED( 'Calendar'[Date] ), [measure] )

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

Hi @CNENFRNL - thanks for the reply, I appreciate the help

 

That logic returns the maximum daily value of the measure rather than weekly...have noted in my other reply the potential way forward though

 

Appreciate the help nonetheless

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure pattern to get your desired result.  Change column/table names as needed.

 

Show Min Max Only =
VAR vThisResult = [Your Measure]
VAR vSummary =
    ADDCOLUMNS (
        ALLSELECTED (
            Date[Year],
            Date[Week]
        ),
        "cResult", [Your Measure]
    )
VAR vMaxResult =
    MAXX (
        vSummary,
        [cResult]
    )
VAR vMinResult =
    MINX (
        vSummary,
        [cResult]
    )
RETURN
    IF (
        OR (
            vThisResult = vMaxResult,
            vThisResult = vMinResult
        ),
        vThisResult,
        BLANK ()
    )





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi @mahoneypat 

 

Thanks for your answer to help me out - appreciate it!

 

I tried that logic but I think the presence of the month column in the table visual creates a filter context that causes the formula to return the max weekly value per month rather than the max weekly value across all months

 

charliedata_2-1607333560767.png

 

If I add the month column to the ALLSELECTED filter so that the evaluation context isn't grouped per month, then I don't quite get what I want - but maybe it's impossible and I just have to remove the month column

charliedata_1-1607333423256.png

 

This is without the month column

charliedata_4-1607333671127.png

 

...which is almost fine except it creates a row for dates that don't have a value for the underlying measure

I could use if(not(isblank as a step to only populate the rows that do have an underlying measure value...perhaps that's the best solution

 

Thanks again for your tip - will go with that unless there's a more effective solution that means the month column can be accommodated (that was my reasoning for using a SUMMARIZE step...but it didn't work)

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors