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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Need help in applying filters and getting multiple column data with respect to ID

Hello All,

 

I am new Power BI and not getting how to apply filter in below condition.

kindly help me on this issue.

I am having Excel data like,

 

DateEmployeeIDSickLeavesPaidLeavesHolidaysUnpaidLeaves
201905011993037Not Well---
201905021993037----
201905031993037-Saturday--
201905041993037-Sunday--
201905051993037----
201905061993037Not Well---
201905071993037----
201905081993037--Holiday-
201905091993037----
201905101993037---For Personal Reason
201905012001234Not Well---
201905022001234Not Well---
201905032001234----
201905042001234-Saturday--
201905052001234-Sunday--
201905062001234----
201905072001234----
201905082001234--Holiday-
201905092001234----
201905102001234----
201905012345654---For Personal Reason
201905022345654----
201905032345654----
201905042345654-Saturday--
201905052345654-Sunday--
201905062345654Not Well---
201905072345654----
201905082345654--Holiday-
201905092345654----
201905102345654----

 

I am trying create a Calculated Column or Measure to achieve folowing result and i am trying to show in Table view like below,

From above Excel data i am trying to display Three columns in Power BI Table as below. But i am not getting how to apply filter so that it will display only Leave date of Employee with ID, Date and Reason. Like this my Excel contains many Employees data for many years.  

LeaveDateEmployeeIDLeaveReason
201905011993037Not Well
201905031993037Saturday
201905041993037Sunday
201905061993037Not Well
201905081993037Holiday
201905101993037For Personal Reason
201905012001234Not Well
201905022001234Not Well
201905042001234Saturday
201905052001234Sunday
201905082001234Holiday
201905012345654For Personal Reason
201905042345654Saturday
201905052345654Sunday
201905062345654Not Well
201905082345654Holiday

 

Kindly help me on this issue.

Thanks in advance!!

 

Regards,

Amar

1 ACCEPTED SOLUTION

Refer the new column in table in the attached file after signature

 

Column = SWITCH(TRUE(),Sheet1[SickLeaves]<>"-",[SickLeaves],[PaidLeaves]<>"-",[PaidLeaves],[Holidays]<>"-",[Holidays],[UnpaidLeaves]<>"-",[UnpaidLeaves],"No Leave")

 

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

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", Int64.Type}, {"EmployeeID", Int64.Type}, {"SickLeaves", type text}, {"PaidLeaves", type text}, {"Holidays", type text}, {"UnpaidLeaves", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","-",null,Replacer.ReplaceValue,{"SickLeaves", "PaidLeaves", "Holidays", "UnpaidLeaves"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Replaced Value", {"Date", "EmployeeID"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"})
in
    #"Removed Columns"

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@Anonymous 

If they are blank the

coalesce(table[SickLeaves],table[PaidLeaves],table[Holidays],table[UnpaidLeaves])

Or try like

switch(true(),
table[SickLeaves]<>"-",table[SickLeaves],
table[PaidLeaves]<>"-",table[PaidLeaves],
table[Holidays]<>"-",table[Holidays],
table[UnpaidLeaves]<>"-",table[UnpaidLeaves],
"Other"
)

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
Anonymous
Not applicable

@amitchandak 

Hello Amit,

 

Thank you so much for your quick response.

I tried creating Calculated column with Switch as above but it not showing as i wanted show. If Employee has not taken any Leave then in the List that Employee should not be listed.

And i am trying to display Date, EmployeeID and LeaveReason if there is Leave for that Employee then only it should display otherwise not. For all employees Saturday and Sunday and Holidays are compulsory to display. So what i am trying here is just filter Leaves column and if any leaves are there then display it Date, EmployeeID and Reason.

By using above switch solution it is displaying only others i.e. false condition for all Employees.

And instead of "-" Excel is having "Blanks".

 

And i tried with "COALESCE" and it showing reasons. But for this i have created Calculated Column and i have added all Leaves Columns in it.

And in Table i have dragged Date , EmployeeID and And this newly created CAlculated column. It shows all Employees Data with Blanks also. But i trying to show only Leaves Data only.

Error.png

 

 

I am trying with applying filters but it is not working. Kindly help!

 

Regards,

Amar

Refer the new column in table in the attached file after signature

 

Column = SWITCH(TRUE(),Sheet1[SickLeaves]<>"-",[SickLeaves],[PaidLeaves]<>"-",[PaidLeaves],[Holidays]<>"-",[Holidays],[UnpaidLeaves]<>"-",[UnpaidLeaves],"No Leave")

 

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
Anonymous
Not applicable

@amitchandak 

Hello Amit,

 

Thanks for your quick response.

It is displaying all Leaves data Correctly. 

What i did here is i have created Calculated column with above DAX. 

I created Table and i inserted Date EmployeeID and Above CAlculated column. And it shows like below,

 
 
 

Error1.PNG

Here i dont want to display other Employees data if they dont have any Leaves. I tried with below DAX but it is showing true or false of 1 or zero.

IF(not ISBLANK('デイリーデータsample'[NGLeavesData]),1)
error3.PNG
i am trying to display only DAte , EmployeeID and Reason. And if remove 1 from IF then gives error.
Kindly help on this .
Thanks in advance!
 
Regards,
Amar
Anonymous
Not applicable

@Anonymous 

You already have blanks instead of "-" in excel, I guess merge in query editor is a much easier way.

1. Merge the 4 columns

merge column.JPG

 

2. Close and Apply, put the columns in a table visual then filter the merged column.

filter out blank.JPG

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors