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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!