March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello!
I need help finding a solution. I have a table containing a list of employees named "Employee List" with two columns: "month" and "name."
I need to determine, for each month:
I initially separated them into two different tables and then merged them. However, this approach is not the most straightforward to update. I want to keep everything in one table to retain historical data.
Thanks fo anyone will read this! 😊
Valeria
Hello, @Valeria group data by month to get a table with 2 columns: month and list of employees. Then create a list of rows with (Table.ToRecords or Table.ToRows - upon your liking). Then run List.Generate to calculate what you want using List.Difference(current, previous) to get those who joined and List.Difference(current, next) to get those who left.
Hello @AlienSx, thanks for responding.
I think I don't need to group. Below example of the data.
can you explain better how I use table.toRecord/ToRows and List. Generate? I am quite new to PowerBi.
Thanks a lot
Valeria
Hello, @Valeria you did not show the result you expected to see in the end so I created columns with ee names as lists (joined and left).
let
Source = your_table,
g = Table.Group(Source, "Month", {{"e", each _[Name]}}),
rows = List.Buffer(Table.ToRecords(g)),
gen = List.Generate(
() =>
[i = 0,
r = rows{0} &
[joined = {},
n_joined = 0,
left = List.Difference(rows{0}[e], try rows{1}[e] otherwise {}),
n_left = List.Count(left)]],
(x) => rows{x[i]}? <> null,
(x) =>
[i = x[i] + 1,
r = rows{i} &
[joined = List.Difference(rows{i}[e], rows{i - 1}[e]),
n_joined = List.Count(joined),
left = try List.Difference(rows{i}[e], rows{i + 1}[e]) otherwise {},
n_left = List.Count(left)]],
(x) => x[r]
),
z = Table.FromRecords(gen)
in
z
Assuming the following definitions:
The following approach would not account for leaves and rejoins, i.e. only the earliest join and the latest leave per employee is listed:
Do you need to consider leaves and rejoins?
Hello Martin, I don't have any dates in my table, just name and month. I need to know the list of names left and the ones joined.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
16 | |
13 | |
13 | |
9 |
User | Count |
---|---|
36 | |
31 | |
20 | |
19 | |
17 |