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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Need help on power BI Multi level ranking

Hi Everyone!

 

Need your help on Power BI Rank Dax function


We have the data like below 

Table Visual

BrandProductSalesRank
AC2001
AD1902
AE1803
AA1704
AF1605
BZ9001
BI8002
BQ7003
BN4004
BB3005
BS2006
CA9001
CB3002
CQ1503
CR1004
CC905
CG806


sales and rank are measure

sales is a dynamic measure , the value of the sales will change based on Time Period (YTD,MTD,QTR)


Sales =

var SelectedMeasure =
SELECTEDVALUE('Time Period'[Time Period],"YTD")

var DynamicMeasureValue =
SWITCH(
TRUE(),
SelectedMeasure = "YTD", [YTD],// gives you the YTD sales
SelectedMeasure = "QTD", [QTD],// gives you the QTD sales
SelectedMeasure = "MTD", [MTD],// gives you the MTD sales
BLANK()
)
RETURN
DynamicMeasureValue


Time Period is a disconnected TABLE. PFB

Time PeriodTime Key
MTD1
QTD2
YTD3

created a slicer out of this table , which will give sales based on the slicer selection(YTD,QTD,MTD)

 

Rank = RANKX(
ALL('TABLE'[Product]),
[Sales]
)

I Just need to apply a filter where Product = Brand
want the output like below

BrandProductSalesRank
AA1704
BB3005
CC905


I have created a flag calclated column to achieve that
flag = IF(
'TABLE'[Brand]='TABLE'[Product],
1,
0
)

I have added this as a visual level filter and selected 1
getting the output like this

BrandProductSalesRank
AA1701
BB3001
CC901



Please help how can we get the desired output like below

BrandProductSalesRank
AA1704
BB3005
CC905



Thanks,

Ananth

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

 

Please change the flag Calculate column to a Measure. Then, the result will look like this.

vcazhengmsft_1-1644387384495.png

 

Best Regards,

Community Support Team _ Caiyun

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous 

 

Please change the flag Calculate column to a Measure. Then, the result will look like this.

vcazhengmsft_1-1644387384495.png

 

Best Regards,

Community Support Team _ Caiyun

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

Anonymous
Not applicable

HI !,

 

Thanks for your response.

 

Actually sales is a dynamic measure , the value of the sales will change based on Time Period (YTD,MTD,QTR)


Sales =

var SelectedMeasure =
SELECTEDVALUE('Time Period'[Time Period],"YTD")

var DynamicMeasureValue =
SWITCH(
TRUE(),
SelectedMeasure = "YTD", [YTD],// gives you the YTD sales
SelectedMeasure = "QTR", [QTD],// gives you the QTD sales
SelectedMeasure = "MTD", [MTD],// gives you the MTD sales
BLANK()
)
RETURN
DynamicMeasureValue


Time Period is a disconnected TABLE. PFB

Time PeriodTime Key
MTD1
QTD2
YTD3

created a slicer out of this table , which will give sales based on the slicer selection(YTD,QTD,MTD)

 

Thanks,

Ananth

AUaero
Responsive Resident
Responsive Resident

I've recreated your data in a test file on my end.  The only thing that I've done that you didn't explicitly say you did was create a measure for sales:

$ Sales = SUM(SampleData[Sales])

The rank measure is:

Rank = 
RANKX(
    ALL(SampleData[Product]),
    SampleData[$ Sales]
)

 and a calculated column for Product = Brand:

ProductBrandMatchFlag = 
IF(
    SampleData[Product] = SampleData[Brand],
    1,
    0
)

I created a table visualization and dropped the ProductBrandMatchFlag filter onto it.  When I filter by ProductBrandMatchFlag = 1 I get your desired result:

AUaero_0-1643899428339.png

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors