The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi all,
Below matrix table is showing Parent SKU sales by customer.
My DAX formula can rank by Parent SKU correctly. However, I don't know how to do the correct ranking within the sub group (by customer) for each Parent SKU.
Can anyone help? Thanks.
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below, and I hope the below can provide some ideas on how to create a solution for your dataset.
Sales total: =
SUM( Sales[Sales] )
Rank by sales: =
VAR _SKUranking =
RANKX ( ALL ( 'SKU Master'[Parent SKU] ), [Sales total:],, DESC )
VAR _CustomerslistbySKU =
FILTER (
SUMMARIZE ( ALL ( Sales ), Customer[Customer], 'SKU Master'[Parent SKU] ),
'SKU Master'[Parent SKU] = MAX ( 'SKU Master'[Parent SKU] )
)
VAR _Customersranking =
RANKX ( _CustomerslistbySKU, [Sales total:],, DESC )
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( Customer[Customer] ), _Customersranking,
ISINSCOPE ( 'SKU Master'[Parent SKU] ), _SKUranking
)
Hi,
Please check the below picture and the attached pbix file.
I tried to create a sample pbix file like below, and I hope the below can provide some ideas on how to create a solution for your dataset.
Sales total: =
SUM( Sales[Sales] )
Rank by sales: =
VAR _SKUranking =
RANKX ( ALL ( 'SKU Master'[Parent SKU] ), [Sales total:],, DESC )
VAR _CustomerslistbySKU =
FILTER (
SUMMARIZE ( ALL ( Sales ), Customer[Customer], 'SKU Master'[Parent SKU] ),
'SKU Master'[Parent SKU] = MAX ( 'SKU Master'[Parent SKU] )
)
VAR _Customersranking =
RANKX ( _CustomerslistbySKU, [Sales total:],, DESC )
RETURN
SWITCH (
TRUE (),
ISINSCOPE ( Customer[Customer] ), _Customersranking,
ISINSCOPE ( 'SKU Master'[Parent SKU] ), _SKUranking
)
Thanks for that. It is very helpful
May I also know how to add the ranking as a slicer? Thanks.
Hi,
Thank you for your feedback. May I ask how is your ranking slicer look like and what does it do?
For instance, if it selects 3, do you want to only show ranking number 3?
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |