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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SteveIOW
Helper II
Helper II

TOPN doesn't work as a filter

Good morning.

 

I have used 

WorstModTrend = TOPN ( 1 , VALUES ( Modalities[Modality] ), CALCULATE([Avg Rise (M)]) , DESC )
to identify the modality with the worst trend.
I now want to identify what that trend is. Obviously I have a table - but in terms of picking it out I need it to appear in a card.
SteveIOW_0-1655893052577.png

 

Non-obstetric unltrasound is produced with no difficulty by the DAX I stated above.

I have tried

WorstTrend = CALCULATE([Avg Rise (M)], Modalities[Modality] = [WorstModTrend])
and it does not work at all.
I have also tried
WorstTrend = CALCULATE([Avg Rise (M)], FILTER(Modalities, [Modality] = [WorstModTrend]))
which just gives me the total trend  (29,943) - not the worst (greatest) trend which is what I need.
 
Is anyone able to help please?
 
Cheers
 
Steve
1 ACCEPTED SOLUTION

Think I have done it myself - by taking a completely different approach.

 

WorstTrend = MAXX(SUMMARIZE(Modalities, Modalities[Modality], "Rise", LinearRegTable[Avg Rise (M)]), LinearRegTable[Avg Rise (M)])
 
I'm sure there is a better way although this gives the right answer. If anyone can give me the another way I will be interested.
 
Cheers

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@SteveIOW , You should try like

 

WorstTrend = CALCULATE([Avg Rise (M)], Modalities[Modality] , TOPN ( 1 , VALUES ( Modalities[Modality] ), CALCULATE([Avg Rise (M)]) , DESC ))

 

do you need bottom means asc

 

WorstTrend = CALCULATE([Avg Rise (M)], Modalities[Modality] , TOPN ( 1 , VALUES ( Modalities[Modality] ), CALCULATE([Avg Rise (M)]) , asc))

 

refer

https://youtu.be/QIVEFp-QiOk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Think I have done it myself - by taking a completely different approach.

 

WorstTrend = MAXX(SUMMARIZE(Modalities, Modalities[Modality], "Rise", LinearRegTable[Avg Rise (M)]), LinearRegTable[Avg Rise (M)])
 
I'm sure there is a better way although this gives the right answer. If anyone can give me the another way I will be interested.
 
Cheers

@amitchandak thanks for having a look at this for me.

 

I have tried as you have written but of course it does not provide a boolean output so it fails. I tried putting in an = instead of a comma but that also fails as below.

 

SteveIOW_0-1655900449376.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.