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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
m_wex
Helper I
Helper I

RANKX issue with previous sales

Having an issue with dynamic ranking and need some advice and guidance.  Multiple attemps have been made to fix this issue but my beginner level skill has kept the solution out of reach. 

 

Have a report showing total sales by part number. The user can select a ranking from a slicer and the corresponding table will shows only those items for the rank selected. 

 

The problem begins when you want to see "all" sales. The ranking works but the outcome is not expected as it is excluding previous years sales which were not sold in the current year. A simple check on an unfiltered table (Rank, Material Number, Current sales, Previous Sales) confirmed that items without sales in the current year have a blank for ranking. Only items with current sales receive a rank, like below.

 

RankMaterialCY SalesPY Sales
 ABC $100.00
 DEF $200.00
1GHI$500.00$300.00

 

This is not unusual as current sales are being ranked but when "All" ranking is selected the expected outcome is to see all current and previous year sales. The part ranking table created does not account for blank rankings. In the above example, the sales total for the previous period would be short $300.00. The expected outcome for All Sales would be CY Sales=$500 and PY Sales=$600.

 

The table being used consists of only maximum values (5,10, 25, 50, 10000). Is there a way to account for blanks? Shown below is the DAX formulas along with a link to a sample file. 

 

Any help would be greatly appreciated - M_Wex

 

m_wex_1-1630790803841.png

Material-Description Sales Ranking =
VAR
RankingDimesion=Values(Sales[Material])
Var
RankingSelect = [Ranking Select PN]
Return
CALCULATE([Total Sales],
Filter( RankingDimesion,
RankX(all(Sales[Material], Sales[Description]) ,[Total Sales], ,desc )<= RankingSelect))

 

Ranking Select PN =
if(HASONEVALUE('Top Part Selection'[Part Rank]) , Values('Top Part Selection'[Park Rank Index] ), blank())
 
Top Part Selection
m_wex_2-1630791119163.png

 

https://1drv.ms/u/s!AnQQfxYxFNvukQijVc8dsTSxBEwo?e=t2NHAo

0 REPLIES 0

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.