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

MAX date for latest nonblank values based on Slicer's date selection

Hi,

 

I need to to get the value of latest "as of date" from the below dataset with below conditon.

 

The lastest "as of date" date should be less than or equal to the selected date in the slicer and within a same deal_ID. So for each deal_ID, I will have a "MAX as of date".

 

Here is the sample data:

deal_idvaluesas of date
1234 30 September 2022
12341900031 August 2022
12342000031 July 2022
1235 30 June 2022
12353000031 May 2022
12354000030 April 2022
1235 31 March 2022
12362300028 February 2022
12362100031 January 2022

 

So as per the above data -

if I select

Date Slicer: 30-Sep-2022

Deal ID Slicer: 1234

my output should be: 19000

 

if I select

Date Slicer: 31-May-2022

Deal ID Slicer: 1235

my output should be: 30000

 

So, basically I need to have first non blank values where MAX "as of date" is less than or equal to the slicer date within a same deal id.

 

Thanks,

RC

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @ramchoudhary ,

 

Check the measure:

Measure = 
var max_date = CALCULATE(MAX('Table'[as of date]),FILTER(ALL('Table'),'Table'[as of date]<=SELECTEDVALUE('Table'[as of date])&&'Table'[deal_id]=SELECTEDVALUE('Table'[deal_id])&&'Table'[values]<>BLANK()))
return
CALCULATE(SUM('Table'[values]),FILTER(all('Table'),'Table'[as of date] = max_date))

vjaywmsft_0-1664960746866.png

It is recommended to create independent slicers to avoid using ALL() function in formula.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
v-jayw-msft
Community Support
Community Support

Hi @ramchoudhary ,

 

Check the measure:

Measure = 
var max_date = CALCULATE(MAX('Table'[as of date]),FILTER(ALL('Table'),'Table'[as of date]<=SELECTEDVALUE('Table'[as of date])&&'Table'[deal_id]=SELECTEDVALUE('Table'[deal_id])&&'Table'[values]<>BLANK()))
return
CALCULATE(SUM('Table'[values]),FILTER(all('Table'),'Table'[as of date] = max_date))

vjaywmsft_0-1664960746866.png

It is recommended to create independent slicers to avoid using ALL() function in formula.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
ramchoudhary
Frequent Visitor

@Ritesh It is not working - 

 

My use case is different than the above given solution.

 

 

ribisht17
Super User
Super User

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.