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
lordmukund
Employee
Employee

Show TOP N Values for each category

Hi, I have 2 queries: 
1.  I want to show Top 5 Workstreams for each Week based on the total count of the Work Items for the particular workstream in a given week.
So in Bar chart I am taking Axis   --> "Week" (It is derived Column from CreatedDate Column) 
In Legend -->  "Workstream"
In Values --> I tried taking Measure ==>  "TOP 5 Workstream" = CALCULATE( COUNT('Bugs DevOps'[Work Items]), TOPN(5,ALL('Bugs DevOps'[Workstream]), COUNT('Bugs DevOps'[Work Items]),DESC), VALUES('Bugs DevOps'[Workstream])  )

 
But I am not getting the Top 5 Legend (Workstream) values instead I am getting all the workstreams. Can someone please help me with the DAX in the measure if I am making some mistake in the above DAX formula.
PFB snips.
 
Top 5.jpgtop 5 fields.jpg
 
 
 
 

2. My 2nd query is that, In Values I can Just take --> "Work Items" (Count of Work Items)

and I can add TOPN visual filter on Legend Field (i.e. Workstream), but I am getting top 5 in only latest Week. PFB Snip FYI.
2 Top 5.jpg
In above snip for Feb Week 8 --> I am not getting Yellow color (with value 15 that is there in above chart). Basically it is giving same TOP 5 Values (based on the latest week) for all the weeks. So is it possible to get Top 5 values (Workstream) for each category (Week) in the chart??

 

Please help me with the above queries. I also need DAX formula for this.

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

Hi @lordmukund ,

Try the following formula to create measures:

Conut Work Items = COUNT('Bugs DevOps'[Work Items])
TOP 5 Workstream = 
VAR Top5Cat =
    CALCULATETABLE (
        GENERATE (
            VALUES ( 'Bugs DevOps'[Week] ),
            TOPN (
                5,
                CALCULATETABLE ( VALUES ( 'Bugs DevOps'[Workstream] ) ),
                [Conut Work Items]
            )
        ),
        ALLSELECTED()
    )
RETURN
    CALCULATE (
        [Conut Work Items] * ( NOT ISEMPTY ( 'Bugs DevOps' ) ),
        KEEPFILTERS ( Top5Cat )
)

v-kkf-msft_0-1614936202902.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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-kkf-msft
Community Support
Community Support

Hi @lordmukund ,

Try the following formula to create measures:

Conut Work Items = COUNT('Bugs DevOps'[Work Items])
TOP 5 Workstream = 
VAR Top5Cat =
    CALCULATETABLE (
        GENERATE (
            VALUES ( 'Bugs DevOps'[Week] ),
            TOPN (
                5,
                CALCULATETABLE ( VALUES ( 'Bugs DevOps'[Workstream] ) ),
                [Conut Work Items]
            )
        ),
        ALLSELECTED()
    )
RETURN
    CALCULATE (
        [Conut Work Items] * ( NOT ISEMPTY ( 'Bugs DevOps' ) ),
        KEEPFILTERS ( Top5Cat )
)

v-kkf-msft_0-1614936202902.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

amitchandak
Super User
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.