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
Anonymous
Not applicable

Power BI: Showing latest 3 dates for a group

Hello everyone, 

I have a problem. I want to show the latest 3 dates only for status "Completed" as illustrated bellow. Tried rankx, topN value and max values approaches, but didn't work out. Basically I need to return the 3 most recent dates just for "Completed" along with any number of results for "Overdue" and "Future" (e.g. regardless of the number of their dates for the latter). A measure must be generated. Any solutions will be highly appreciated.

KirilGeorge23_0-1669298993781.png

Thanks, KGeorge

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1669320988776.png

 

A showcase of powerful Excel formula,

CNENFRNL_1-1669321063463.png


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!

View solution in original post

5 REPLIES 5
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1669320988776.png

 

A showcase of powerful Excel formula,

CNENFRNL_1-1669321063463.png


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

Hello , thank you for you solution. As I specified the main goal is to have a measure with the latest 3 dates for completed; no filter / no ranks ( having anydates) for overdo and future status in one cumulative table. However, I believe your proposition is approaching the final solution of the issue.

Regards,

K.

tamerj1
Super User
Super User

Hi @Anonymous 

please try

FilterMeasure =
VAR CurrentDate =
SELECTEDVALUE ( 'Table'[Date] )
VAR CurrentStatus =
SELECTEDVALUE ( 'Table'[Status] )
VAR T1 =
CALCULATETABLE ( VALUES ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR T2 =
TOPN ( 3, T1, 'Table'[Date], ASC )
RETURN
IF ( CurrentStatus = "Completed", IF ( CurrentDate IN T2, 1 ), 1 )

 

place this measure in the filter pane of the visual and select "is not blank" then spply the filter

FreemanZ
Super User
Super User

try to create a new table with the code below:

Table =
VAR Table1 =
    FILTER(
        TableName,
        TableName[Status] = "Completed"
    )
VAR Table2=
TOPN(
    3,
    Table1,
    TableName[Date]
)
RETURN Table2
 
I tried and it worked like this:
FreemanZ_0-1669301817242.png
Anonymous
Not applicable

Thank you very much for the response, I haven't specified that I need a measure , where the top 3 "Completed" will be shown along with the other status "Overdue","Future", regardless of both numbers of results.

 

 

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.

Top Solution Authors