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

How to number website interactions in Power BI?

Hi, I have this table:

AndrejBI_0-1614084318944.png

And this is what I want to achieve: 

AndrejBI_1-1614084363187.png

 

It's basically like an index yet it starts again every time there is a new ID in its way. I guess it should be possible in Power Query, do you have any idea how to achieve this? 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFV0lEyMNQHIiMDIwMFMysDC6CIf1FKapFSrA4uNeZAkcCYUgMDIzNHPMqMgCIe+bmpCgGJ6algdUZGRoaGqOpMrUzMUazErsYU1axYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Time = _t, Page = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Time", type datetime}, {"Page", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID", "Time"}, {{"All", each _, type table [ID=nullable number, Time=nullable datetime, Page=nullable text]}}),
    #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"ID"}, {{"All", (tableint) => let sort = Table.Sort(tableint,{"Time", Order.Ascending}), AddIndex = Table.AddIndexColumn(sort,"Index",1) in AddIndex}}),
    #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows1", "All", {"Time", "Index"}, {"Time", "Index"})
in
    #"Expanded All"

index.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Icey
Community Support
Community Support

Hi @Anonymous ,

 

Try this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFV0lEyMNQHIiMDIwMFMysDC6CIf1FKapFSrA4uNeZAkcCYUgMDIzNHPMqMgCIe+bmpCgGJ6algdUZGRoaGqOpMrUzMUazErsYU1axYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Time = _t, Page = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Time", type datetime}, {"Page", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"ID", "Time"}, {{"All", each _, type table [ID=nullable number, Time=nullable datetime, Page=nullable text]}}),
    #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"ID"}, {{"All", (tableint) => let sort = Table.Sort(tableint,{"Time", Order.Ascending}), AddIndex = Table.AddIndexColumn(sort,"Index",1) in AddIndex}}),
    #"Expanded All" = Table.ExpandTableColumn(#"Grouped Rows1", "All", {"Time", "Index"}, {"Time", "Index"})
in
    #"Expanded All"

index.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Tahreem24
Super User
Super User

@Anonymous  - Create a calculated column with below DAX:

Column = RANKX(Table,Table[Page],,ASC,Dense)
Capture.PNG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Hi  @Tahreem24 ,

 

I am having troubles using the formula: 

AndrejBI_1-1614164306578.png

This is my table: 

AndrejBI_2-1614164393455.png

 

@Anonymous  Have you created measure or calculated column?

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

That was quick! Thanks a lot, I actually want to rank it based on the time. So what was the first, second, and...  interaction on the website. Also, is it somehow possible to transform this measure into a column using Power Query? 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.