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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
rssilvaba
Resolver II
Resolver II

Top n results where n is based on a measure or expression

Hi all, the following file has some sample data and in the table visual I am trying to display all the topn Urgent Items based on the "Total Number of Urgent requests"-"Goal" rounded up.

In the case of the current view in the sample that would be top 3 ordered from newest to oldest created date.

https://drive.google.com/file/d/1WFBlvVHV7cS4F519BP-UphHRPhNi4gtb/view?usp=sharing

1 ACCEPTED SOLUTION

Hi @rssilvaba ,

You can try this measure:

Goal = 
VAR top3 =
    COUNTX (
        TOPN ( 3, ALLSELECTED ( Requests[Created] ), 'Requests'[Created], DESC ),
        'Requests'[Created]
    )
RETURN
    top3 / [Total Number Urgent Requests]

topn.png

Attached the modified sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
Greg_Deckler
Super User
Super User

@rssilvaba - Adding that measure to the visual returns 1 for every row. Where is "Goal"?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler "Goal" is the KPI Target Urgent Requests

Hi @rssilvaba ,

You can try this measure:

Goal = 
VAR top3 =
    COUNTX (
        TOPN ( 3, ALLSELECTED ( Requests[Created] ), 'Requests'[Created], DESC ),
        'Requests'[Created]
    )
RETURN
    top3 / [Total Number Urgent Requests]

topn.png

Attached the modified sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

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.