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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ToPa
New Member

Calculate max value in date range and display only top result

Hi!

 

I have tried to search for similar cases, but can not seem to find the correct solution for creating this measure.

I have two tables - Date Dim and Fact Product. Dim date has date values and Fact Product as below (example data)

(The Value-column is a calculated column and I can not filter Top N by this value in the visual.)

 

IDProductColorValueValue Date
1ABC123Red

300

1/30/24
2ABC123Red4251/30/24
3ABC123Red1501/30/24
4DEF456Blue2252/2/24
5DEF456Blue1502/2/24
6ABC123Red2002/3/24
7ABC123Red1231/28/24
8ABC123Red5001/31/24

 

When selecting a date range from Dim Date in a slicer, I would like to calculate the values for the rows with same product name and color and find which Value Date this was found. I do not want to see all products that date, or all colors - only the one that meet the requirments.

 

Expected result from example 

Selected date range 12/11/23 - 2/3/24 in slicer, visual should display:

ProductColorValueValue Date
ABC123Red8751/30/24

 

If selected date range is 2/2/24 - 2/3-24, visual should display:

ProductColorValueValue Date
DEF456Blue3752/2/24

 

Any idea on how this can be achieved? 🙂

1 ACCEPTED SOLUTION
talespin
Solution Sage
Solution Sage

hi @ToPa 

 

You can use RANK, I have used Date from Fact table, need to check how to use date from Date table in Rank. Apply visual filter on measure rank = 1.

 

Rank =
VAR _Rank =
RANK(
        DENSE,
        ALLSELECTED(TestTbl5[Product], TestTbl5[Color], TestTbl5[Value Date]),
        ORDERBY( [Sum Value], DESC)
)
 
RETURN _Rank
 
talespin_0-1707313607291.png

 

View solution in original post

1 REPLY 1
talespin
Solution Sage
Solution Sage

hi @ToPa 

 

You can use RANK, I have used Date from Fact table, need to check how to use date from Date table in Rank. Apply visual filter on measure rank = 1.

 

Rank =
VAR _Rank =
RANK(
        DENSE,
        ALLSELECTED(TestTbl5[Product], TestTbl5[Color], TestTbl5[Value Date]),
        ORDERBY( [Sum Value], DESC)
)
 
RETURN _Rank
 
talespin_0-1707313607291.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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