Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
fsim
Responsive Resident
Responsive Resident

grouping and conditional fitlering

hello,

here is my today issue : 
I want to remove the records of a date for each users as soon as there is a day off showing for that day.

 Should I go for some grouping then, filtering ? but how can I filter on somehing that is not allways there ?

 

userIDTypeProjectIdhours Listdate userIDTypeProjectIdhours Listdate
17755201workalpha430/03/2022 17755201workalpha430/03/2022
17755201workbeta430/03/2022==>17755201workbeta430/03/2022
17755201workalpha431/03/2022 17755201day offsick831/03/2022
17755201day offsick831/03/2022      
1 ACCEPTED SOLUTION
fsim
Responsive Resident
Responsive Resident

My solution so far:

group by peopleid and listdate , keep all the rows.

then, I created a function to manage those tables :

 

(mytable) =>
let
Source = Table.AddColumn(mytable, "Custom", each if [Category] = "Time Off" then 1 else 0),
max = List.Max(Source[Custom]),
Custom1 = Table.SelectRows(Source, each [Custom] = max)
in
Custom1

 

what it does:

it add a column that contains 1 if there is a time off and 0 for the other rows.

I find the maximum of this new column and use it to filter the table. it keeps the 1 if it exist else the 0

and I return the modified table. 

then I simply expand all the tables to get my rows back.

 

I'm pretty sure I shouldn't use a function to do the job. anyway it's working. 

 

View solution in original post

5 REPLIES 5
fsim
Responsive Resident
Responsive Resident

My solution so far:

group by peopleid and listdate , keep all the rows.

then, I created a function to manage those tables :

 

(mytable) =>
let
Source = Table.AddColumn(mytable, "Custom", each if [Category] = "Time Off" then 1 else 0),
max = List.Max(Source[Custom]),
Custom1 = Table.SelectRows(Source, each [Custom] = max)
in
Custom1

 

what it does:

it add a column that contains 1 if there is a time off and 0 for the other rows.

I find the maximum of this new column and use it to filter the table. it keeps the 1 if it exist else the 0

and I return the modified table. 

then I simply expand all the tables to get my rows back.

 

I'm pretty sure I shouldn't use a function to do the job. anyway it's working. 

 

amitchandak
Super User
Super User

@fsim , This record is not there on right. how to know day off

17755201 work alpha 4 31/03/2022  
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
fsim
Responsive Resident
Responsive Resident

hi @amitchandak ,

Sorry, the forum disruped my table a little bit. I know it's a day off because the user encoded it at the same date than the planned work.  Same userid, same Listdate.  I can build a sub table. Then, If one reccord from this subtable is type="time off" then I delete all the other lines, else, I keep them all

 

 

@fsim , remove duplicate in power query by selecting the columns(or all columns) which are creating the duplicate

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
fsim
Responsive Resident
Responsive Resident

nope, because some duplicates are to be kept if there is no day off on that day

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors