I have a matrix table with 2 fields: states ,e.g - Texas, California and products sell in this states. this two tables are connected trhough fact table. I'm doing a ranking where the main is order the sum of sale per state and per product, but for some reason the ranking for some states is starting with 2 or even duplicate.
RANKX(all('fid dim_product'),[value],,DESC,Dense)
Solved! Go to Solution.
Hi @Anonymous ,
Try to refer to my formulas.
//Measure
__SUM =
SUMX(
FILTER( ALL(Sheet3), [State] = MAX([State]) && [Product] = MAX([Product]) ),
[qty]
)
//Measure
Rank =
RANKX(
FILTER( ALLSELECTED(Sheet3), [State] = MAX([State]) ),
[__SUM],
, ASC, Dense
)
If it's incorrect, please provide the sample data of your tables(We need sample data for fact table and dimension table).
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Try to refer to my formulas.
//Measure
__SUM =
SUMX(
FILTER( ALL(Sheet3), [State] = MAX([State]) && [Product] = MAX([Product]) ),
[qty]
)
//Measure
Rank =
RANKX(
FILTER( ALLSELECTED(Sheet3), [State] = MAX([State]) ),
[__SUM],
, ASC, Dense
)
If it's incorrect, please provide the sample data of your tables(We need sample data for fact table and dimension table).
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you can share a link to your pbix file or paste your example data in a reply (so it can be easily copied), a specific solution can be suggested.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
hi @mahoneypat , this is my data behaviour. sometimes the ranking works, sometimes not. I think this should hapeen due to context filter. the tables states and products are separeted
State
California qty myranking
Iphone 1500 2
Galaxy 1279 2
Huawei 950 3
Texas qty myranking
Iphone 800 1
Galaxy 279 2
Huawei 90 3
thanks for help me
@Anonymous , check do you have null/blank value in fid dim_product or a value missing in fid dim_product which there in the table having columns for measure [value]
If you share some example data, a specific solution can be suggested. You should use RANKX over a column, not the whole table. That removes all the filters from that table; the state with 2 probably doesn't have sales for the top product.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
User | Count |
---|---|
116 | |
62 | |
59 | |
48 | |
39 |
User | Count |
---|---|
111 | |
65 | |
63 | |
51 | |
48 |