Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi
I have a table as per below (simplified for the purposes here). You can see it does leave the rows in if both are Current. I am just trying to get rid of first the rows where ROLEnumber is the same and there is a Current and Left (with Left being removed). Not sure how to do this most easily.
StaffID | ROLEnumber | Status |
12345 | 0001 | Current |
12345 | 0001 | Left |
23456 | 0006 | Current |
23456 | 0007 | Current |
34765 | 0009 | Left |
45673 | 0015 | Left |
45673 | 0015 | Current |
65523 | 0021 | Current |
65523 | 0021 | Current |
Once the filter is applied the table should then show:
StaffID | ROLEnumber | Status |
12345 | 0001 | Current |
23456 | 0006 | Current |
23456 | 0007 | Current |
34765 | 0009 | Left |
45673 | 0015 | Current |
65523 | 0021 | Current |
65523 | 0021 | Current |
Solved! Go to Solution.
Hi @83dons,
Thank you for reaching out to the Microsoft fabric community forum.
I have reproduced your scenario in Power BI Desktop and achieved the expected output as per your requirement:
Expected Output (Achieved):
I used Power Query (Transform Data) in Power BI and applied logic to:
For your reference, I’ve attached the .pbix file so you can explore the full solution and steps applied.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @83dons,
Thank you for reaching out to the Microsoft fabric community forum.
I have reproduced your scenario in Power BI Desktop and achieved the expected output as per your requirement:
Expected Output (Achieved):
I used Power Query (Transform Data) in Power BI and applied logic to:
For your reference, I’ve attached the .pbix file so you can explore the full solution and steps applied.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hi @v-ssriganesh this appears to work as expected, although when I expand all the rows in the table in the last step is has changed all the data types to ABC123 from what they were originally. How do I avoid this happening and retain the same data types that were in the existing columns? It also adds 'FilteredRows.' before each column name which I am going to have to change back now is there a way of avoiding this also or quick way to remove it from all columns at once?
Hi @83dons,
Thank you for your follow up.
Yes, both the change in data types and the "FilteredRows." prefix are expected behaviors when expanding nested tables in Power Query, but you can handle them easily. Here's how:
To quickly remove the prefix:
If this information resolves your issue, please “Accept as Solution” and give a "Kudos" to help other community members.
Thank you.
Hello @83dons
You can try this M Code
let
Source = YourSourceStep,
Grouped = Table.Group(Source, {"StaffID", "ROLEnumber"}, {{"GroupedData", each _, type table [StaffID=number, ROLEnumber=text, Status=text]}}),
AddHasCurrent = Table.AddColumn(Grouped, "HasCurrent", each List.Contains([GroupedData][Status], "Current")),
Expanded = Table.ExpandTableColumn(AddHasCurrent, "GroupedData", {"StaffID", "ROLEnumber", "Status"}),
Filtered = Table.SelectRows(Expanded, each ([Status] = "Current" or [HasCurrent] = false)),
RemovedHasCurrent = Table.RemoveColumns(Filtered,{"HasCurrent"})
in
RemovedHasCurrent
Thanks,
Pankaj Namekar | LinkedIn
If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.
Hi @83dons In Power Query, group the data by StaffID and ROLEnumber, and keep all rows in a new column. Then, use a custom column to filter groups:
if List.Contains([Statuses][Status], "Current") then Table.SelectRows([Statuses], each [Status] = "Current") else [Statuses]
Expand the filtered rows and remove intermediate columns.
Hi @Akash_Varuna I prefer the graphical approach so will have a go at your solution. What next? Not sure what to populate the query with.
User | Count |
---|---|
70 | |
70 | |
34 | |
23 | |
22 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |