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
hymieho
Resolver I
Resolver I

Show Top 15 and Bottom 5 results in same visualization / bar chart

I am trying to create a chart that includes both the top 10 and bottom 5 items. I have looked high and low and I cannot figure it out. I am able to get them each separately, but showing them in the same bar chart has been a challenge.

 

The core table 'Daily Margin' has a row for each product sold for the day and its raw margin.  I also have the following measures:

 

  1. [Sum of RM] = SUM('Daily Margin'[RM ($)])
  2. [Rank (Desc) of Product Line by RM] = RANKX(ALLSELECTED('Daily Margin'[Product Line]),[Sum of RM],,DESC)
  3. [Rank (Asc) of Product Line by RM] = RANKX(ALLSELECTED('Daily Margin'[Product Line]),[Sum of RM],,ASC)

 

I currently have two bar charts

  1. "Top 15" where [Product Line] on the axis, a measure as the value, [RM ($)] as the value, and in the Visual Level Filter I have Rank (Desc) is less than or equal to 15
  2. Same as above, but for "Bottom 5" where the filter is Rank (Asc) of Product Line by RM is less than or equal to 5.

They work great, but I would like the results of both to be combined in one chart. I tried creating a calculated column (and measure for that matter) that would be TRUE() if either of the above RANKX measures were true, with the intent to filter the chart on the calculated column but that did not work--the calculated columns always returned TRUE():

Top15Bottom5 = if(OR([Rank (Desc) of Product Line by RM] <= 15, [Rank (Asc) of Product Line by RM] <= 5),TRUE(), FALSE())

I thought of calculating the MAX number of ranks and taking the top 15 and bottom 5:

RankCount = MAXX('Daily Margin',RANKX(ALLSELECTED('Daily Margin'[Product Line]),[Sum of RM],,DESC))

But I can't use use formulas in filter conditions, ex: Rank (Desc) is less than or equal to 15 OR Rank (Desc) is greater than or equal to ([RankCount] - 5)

 

HELP??? Smiley Happy Thanks!

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@hymieho

 

Create a new Measure:

 

Flag = if(or([Rank (Desc) of Product Line by RM] <16;[Rank (Asc) of Product Line by RM]<6);1;0)

 

In visual level filter Use Flag equal to 1

 

Both Ranks are measures too.

 

Rnk.png

 

 

 

 




Lima - Peru

View solution in original post

2 REPLIES 2
Vvelarde
Community Champion
Community Champion

@hymieho

 

Create a new Measure:

 

Flag = if(or([Rank (Desc) of Product Line by RM] <16;[Rank (Asc) of Product Line by RM]<6);1;0)

 

In visual level filter Use Flag equal to 1

 

Both Ranks are measures too.

 

Rnk.png

 

 

 

 




Lima - Peru

If it were a snake it would have bit me. Thanks! 

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.