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

Dynamic row numbers based on Rank Column

Hell All,

 

I have written a calculated column to get the ranks for each sbu's employee count.

Formula:-

 

 

Ranks = 
    RANKX(
        FILTER('Table','Table'[Date]=EARLIER('Table'[Date])),
        'Table'[Count],,,Dense)

Ouput:-

Capture.PNG

Now i would like to get the count of rows which changes dynamically based on rank column.
i.e

SBUCountRanksRowNum
A3311
B922
C533
D344
E345
F256
G257
H168
I169
J1610

 

 

Can anyone please suggest me for the same.

 

Thanks

Mohan V

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Well i got a solution on my own..but its not by using DAX..
Its magic power query.

 

Solution:-

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdFNCoAgEIbhu8xaMJ0iW1ba3xXE+18jUSonvp08DDO8GCPNpKjXVtvOuPycKKlIi0RTcJXIBb1EWzCgyQ3t3BEeEoeCJzp0/Q7VSzWJH3VNEqMklks9wiCxTWKUxCjpxbFJYpT0Yf6QdAM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [SBU = _t, Date = _t, Count = _t]),
    #"Changed Type1" = Table.TransformColumnTypes(Source,{{"Count", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Date", Order.Ascending}, {"Count", Order.Descending}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"Count", Int64.Type}, {"Date", type date}}),

    Partition = Table.Group(#"Changed Type", {"Date"}, {{"Count", each Table.AddIndexColumn(_, "Index2",1,1), type table}}),
    #"Expanded Count" = Table.ExpandTableColumn(Partition, "Count", {"SBU", "Count", "Index2"}, {"SBU", "Count.1", "Index2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Count",{{"SBU", type text}, {"Count.1", Int64.Type}, {"Index2", Int64.Type}})
in
    #"Changed Type2"

Thanks for the help @v-shex-msft

 

View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

Power bi not support create dynamic calculated column/table based slicer or filter. you need to use measure to instead.

Calculated Column/Table Change Dynamically According to Slicer Selection in the Report.

 

Regard,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msft Thanks for the confirmation.

Well i think i need to go by a workaround solution for what i am looking for.

I ll give you detailed infor regarding the report that i am creating.
I hope and i wish you will come up with some suggestions or workaround solutions.

 

Actually, i am creating report, which is having all the cards visual for each sbu.

if i have ten sbu's then ten cards visual for each sbu which shows the emp count.

Now i would like to show these cards by their ranks based on emp count, which are changing dynamically for each day for each sbu.

i.e the top rank sbu card will be first and then the second by putting this ranks calculated column in visual level filter.

But here as you know some of the sbu's having same no emp count, then i cant go with ranks.

 

So thats the reason i would like to have a column or measure which will be giving the index/rownum based on the ranks.

 

Expected output:-

SBUCountRanksIndex
A344
B256
C168
D3311
E345
F257
G922
H169
I533
J1610

 

 

So here if you see, 4,5,6 ranks are getting repeated.

for those i would like to have a column or measure which will give me 

 

Please help.

 

Mohan V

Anonymous
Not applicable

Well i got a solution on my own..but its not by using DAX..
Its magic power query.

 

Solution:-

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdFNCoAgEIbhu8xaMJ0iW1ba3xXE+18jUSonvp08DDO8GCPNpKjXVtvOuPycKKlIi0RTcJXIBb1EWzCgyQ3t3BEeEoeCJzp0/Q7VSzWJH3VNEqMklks9wiCxTWKUxCjpxbFJYpT0Yf6QdAM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [SBU = _t, Date = _t, Count = _t]),
    #"Changed Type1" = Table.TransformColumnTypes(Source,{{"Count", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Date", Order.Ascending}, {"Count", Order.Descending}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"Count", Int64.Type}, {"Date", type date}}),

    Partition = Table.Group(#"Changed Type", {"Date"}, {{"Count", each Table.AddIndexColumn(_, "Index2",1,1), type table}}),
    #"Expanded Count" = Table.ExpandTableColumn(Partition, "Count", {"SBU", "Count", "Index2"}, {"SBU", "Count.1", "Index2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Expanded Count",{{"SBU", type text}, {"Count.1", Int64.Type}, {"Index2", Int64.Type}})
in
    #"Changed Type2"

Thanks for the help @v-shex-msft

 

Anonymous
Not applicable

Can you please provide this solution in dax .. power query is quite complecated to understand.

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.