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

Take max from set of dates based on date slicer in power bi

Hi,

 

I need to to get the max "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 dateDesired output
1234 30 September 202231 August 2022
12341900031 August 202231 August 2022
12342000031 July 202231 August 2022
1235 30 June 202231 May 2022
12353000031 May 202231 May 2022
12354000030 April 202231 May 2022
1235 31 March 202231 May 2022
12362300028 February 202228 February 2022
12362100031 January 202228 February 2022

So as per the above data -

if I select

Date Slicer: 30-Sep-2022

Deal ID Slicer: 1234

my output should be: 31 August 2022

 

if I select

Date Slicer: 31-May-2022

Deal ID Slicer: 1235

my output should be: 31 May 2022

 

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

 

Thanks,

RC

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

Hi @ramchoudhary ,

 

Probably you need this calculated column:

 

Desired output = MAXX(FILTER('Table',[deal_id]=EARLIER('Table'[deal_id])&&[values]<>BLANK()),[as of date])

vstephenmsft_0-1664789410626.png

 

 

Best Regards,

Stephen Tao

 

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

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @ramchoudhary ,

 

Probably you need this calculated column:

 

Desired output = MAXX(FILTER('Table',[deal_id]=EARLIER('Table'[deal_id])&&[values]<>BLANK()),[as of date])

vstephenmsft_0-1664789410626.png

 

 

Best Regards,

Stephen Tao

 

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

 

jgeddes
Super User
Super User

 Try the measure 

 

Output =
var _selectedDate =
SELECTEDVALUE('Table (5)'[as of date])
var _dealID =
LOOKUPVALUE('Table (5)'[deal_id],'Table (5)'[as of date],_selectedDate)
Return  
CALCULATE(
    MAX('Table (5)'[as of date]),
    FILTER(ALL('Table (5)'), 'Table (5)'[deal_id] = _dealID && NOT(ISBLANK('Table (5)'[values])))
)



Did I answer your question? Mark my post as a solution!

Proud to be a 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.