The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi Team,
I have a problem, I am trying to sort based upon the measure the hierarchy in matrix should be sorted in descending order
Measure
in my raw data the scenario column contains
Actual
Budget
MTP
RBU1
RBU2
Now when im trying to sort the matrix based upon the rankx
Solved! Go to Solution.
Hi @Varshini1234567,
I believe you need to tweak the DAX logic. Could you please use below DAX logic to get non blank projects
Rank =
Var LV = SELECTEDVALUE(RowMatrix[slicer column])
var nonblank = FILTER(
ALL(Raw_Data),
NOT(ISBLANK([Plan_3pages]))&&
Raw_Data[Scenario] = LV &&
Raw_Data[Project Name] <> BLANK()
)
RETURN
SWITCH(
TRUE(),
// Case: Project Name is visible in the matrix
ISINSCOPE(Raw_Data[Project Name]),
IF(
ISBLANK([Plan_3pages]), BLANK(),
RANKX(
nonblank,
[Plan_3pages],
,
DESC,
DENSE
),
BLANK()
),
// Budget
LV = "Budget", && ISINSCOPE(Raw_Data[pg Budget]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg Budget]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg Budget]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
// MTP
LV = "MTP" && ISINSCOPE(Raw_Data[pg MTP]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg MTP]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg MTP]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
LV = "RBU1" && ISINSCOPE(Raw_Data[pg rbu1]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg rbu1]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg rbu1]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
LV = "RBU2" && ISINSCOPE(Raw_Data[pg rbu2]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg rbu2]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg rbu2]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
BLANK()
)
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi @Varshini1234567 ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @Varshini1234567 ,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @ajaybabuinturi @freginier for the prompt response.
I wanted to check if you had the opportunity to review the information provided and resolve the issue..? If the response has addressed your query, please accept it as a solution, so other members can easily find it.
Thank you.
Hi @Varshini1234567,
I believe you need to tweak the DAX logic. Could you please use below DAX logic to get non blank projects
Rank =
Var LV = SELECTEDVALUE(RowMatrix[slicer column])
var nonblank = FILTER(
ALL(Raw_Data),
NOT(ISBLANK([Plan_3pages]))&&
Raw_Data[Scenario] = LV &&
Raw_Data[Project Name] <> BLANK()
)
RETURN
SWITCH(
TRUE(),
// Case: Project Name is visible in the matrix
ISINSCOPE(Raw_Data[Project Name]),
IF(
ISBLANK([Plan_3pages]), BLANK(),
RANKX(
nonblank,
[Plan_3pages],
,
DESC,
DENSE
),
BLANK()
),
// Budget
LV = "Budget", && ISINSCOPE(Raw_Data[pg Budget]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg Budget]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg Budget]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
// MTP
LV = "MTP" && ISINSCOPE(Raw_Data[pg MTP]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg MTP]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg MTP]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
LV = "RBU1" && ISINSCOPE(Raw_Data[pg rbu1]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg rbu1]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg rbu1]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
LV = "RBU2" && ISINSCOPE(Raw_Data[pg rbu2]),
IF(
CONTAINSSTRING(SELECTEDVALUE(Raw_Data[pg rbu2]), "Others"),
999,
RANKX(
ALLSELECTED(Raw_Data[pg rbu2]),
[Plan_3pages],
,
DESC,
DENSE
) *
RANKX(
ALLSELECTED(Raw_Data[SET Area]),
[Plan_3pages],
,
DESC,
DENSE
)
),
BLANK()
)
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi,
You can fix the sorting and blank issue with two key changes:
Exclude 'Actual' rows directly in your measure using:
Avoid ranking blank values to prevent them from appearing first:
Also, don’t use ALLSELECTED without filtering, as it brings back 'Actual'. Use FILTER(...) inside RANKX to exclude blanks and "Others" cleanly.
freginier
User | Count |
---|---|
69 | |
68 | |
65 | |
54 | |
28 |
User | Count |
---|---|
112 | |
82 | |
65 | |
48 | |
43 |