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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
MarkPHarris1
Helper I
Helper I

Next 5 tasks to take place in DAX

Hi there,

 

I have a requirement to only show the next 5 tasks that are taking place in a table of tasks, I tried using the Top N filter in the filter pane, and it didn't take into account if I filtered it to one project above a task(I want to see the next 5 future tasks by project). I tried to remake the calculation using rankx eg. 

RANKX(ALLSELECTED('Tasktable'),CALCULATE(MIN('Tasktable'[Taskdate]),'Tasktable'[Taskdate] >= TODAY())) but it just showed 1's for all the different tasks. Can you help at all in suggesting some DAX that could make this achievable?
 
Thanks for your help in advance,
 
Mark
1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @MarkPHarris1 ,

According to my understanding, you want to display the next 5 rows which date is later than today , right?
You could use the following formula:

top5 =
IF (
    SELECTEDVALUE ( TaskTable[Taskdate] )
        IN TOPN (
            5,
            FILTER (
                CALCULATETABLE ( DISTINCT ( TaskTable[Taskdate] ), ALL ( TaskTable ) ),
                TaskTable[Taskdate] > TODAY ()
            ),
            [Taskdate], ASC
        ),
    1,
    0
)

Then apply the top5=1 filter on this visual like this:

8.12.7.PNG

Is the result what you want? If not, please upload some data samples and expected output.
Please do mask sensitive data before uploading.

 

Best Regards,
Eyelyn Qin

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @MarkPHarris1 ,

According to my understanding, you want to display the next 5 rows which date is later than today , right?
You could use the following formula:

top5 =
IF (
    SELECTEDVALUE ( TaskTable[Taskdate] )
        IN TOPN (
            5,
            FILTER (
                CALCULATETABLE ( DISTINCT ( TaskTable[Taskdate] ), ALL ( TaskTable ) ),
                TaskTable[Taskdate] > TODAY ()
            ),
            [Taskdate], ASC
        ),
    1,
    0
)

Then apply the top5=1 filter on this visual like this:

8.12.7.PNG

Is the result what you want? If not, please upload some data samples and expected output.
Please do mask sensitive data before uploading.

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

Hi @MarkPHarris1  Have a look at this https://www.daxpatterns.com/ranking/

This is the daxpatterns version 2 which includes solutions from Power BI perspective along with samples and videos. I would recommend you go through full page you will find your solution.

 

Appreciate a Kudos.

Please mark it as solution if this resolves your problem.

 

Thanks

 

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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