Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello,
I am having issues implementing a unique login tracker for a data set I have. Firsly, a unique login is classed as an individual users first login within a 24 hour time period. However the time periods do not align with days, the 24 hour period starts from the users first login, that is unique. For example I log in for the first time at 5pm, all logins for the next 24 hours are not unique. Then 2 days later I sign in at 9pm, then the next 24hrs of logins are not unique.
Ideally the column would return a true if unique, a false if not.
Below is an example of the data.
Solved! Go to Solution.
If you want it in M...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUbLQN9Q3MlQwNLUyMFCK1UEVNMMmaA4TdEIStMCmEqugJaqgEVjQBJugKapFRti0G2NzkglY0ACLoBFEMBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Login = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
ChangedType = Table.TransformColumnTypes(#"Added Index",{{"Login", type datetime}}),
#"Grouped Rows" = Table.Group(ChangedType, {"User"}, {{"Gr", each Table.AddColumn(_, "Unique", each let
l=List.Transform(ChangedType[Login], Number.From),
x=List.Accumulate(l, {l{0}}, (s,c)=> if c< List.Last(s)+1 then s else s&{c})
in
List.Contains(x,Number.From([Login]))) , type table}}),
#"Expanded Gr" = Table.ExpandTableColumn(#"Grouped Rows", "Gr", {"Index", "Login", "Unique"}, {"Index", "Login", "Unique"}),
#"Sorted Rows" = Table.Sort(#"Expanded Gr",{{"Index", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in
#"Removed Columns"
Hi @HarveyM
Where do you want this, in a calculated column?
Do you want to share some sample data with the expected result?
What would happen if you have a user login once every hour for three days in a row? What do you count as unique apart from the very first login?
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @AlB
Yes it would be good in a custom column.
Below is some exapmle data with the expected result.
So from the last login, every login until 07/07/2021 19.09 will not be unique as they fall into the last 24hr window.
In regards to your question, the frist login for each 24 hour period would be uniqe, the subsquent 23 for the rest of the day are not unique. In total you would have 3 unique logins.
If you want it in M...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUbLQN9Q3MlQwNLUyMFCK1UEVNMMmaA4TdEIStMCmEqugJaqgEVjQBJugKapFRti0G2NzkglY0ACLoBFEMBYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [User = _t, Login = _t]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
ChangedType = Table.TransformColumnTypes(#"Added Index",{{"Login", type datetime}}),
#"Grouped Rows" = Table.Group(ChangedType, {"User"}, {{"Gr", each Table.AddColumn(_, "Unique", each let
l=List.Transform(ChangedType[Login], Number.From),
x=List.Accumulate(l, {l{0}}, (s,c)=> if c< List.Last(s)+1 then s else s&{c})
in
List.Contains(x,Number.From([Login]))) , type table}}),
#"Expanded Gr" = Table.ExpandTableColumn(#"Grouped Rows", "Gr", {"Index", "Login", "Unique"}, {"Index", "Login", "Unique"}),
#"Sorted Rows" = Table.Sort(#"Expanded Gr",{{"Index", Order.Ascending}}),
#"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in
#"Removed Columns"
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 4 |