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

Join 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

Reply
tom1tas
Frequent Visitor

Create filtered table based on max value

Hello All, appreciate your help in this.
I am trying to filter my table, by getting one company value for each date, there are some cases where one employee worked for two companies during the same day and I need to filter the data for the one that has a higher time duration.

Conditions For the filter

  • Keep Company with the higher duration for each day
  • Keep all dates available 
  • In case duration for both companies is exactly the same during the same day, keep wichever butt keep only one daily.  


Current Table

Reported DateEmployeeEmployee IDTotal DurationCompany
12/1/2022Andy1238Cars Company
12/1/2022Andy1237Mobile Company
12/1/2022Sam3218Chicken Company
12/1/2022Sam3218
Cars Company

 

12/3/2022Dan4565Soups Company
2/2/2023Sam1238Soups Company

 

Expected filtered Table

Reported DateEmployeeEmployee IDTotal DurationCompany
12/1/2022Andy1238Cars Company
12/1/2022SAm3218Chicken Company
12/3/2022Dan4565Soups Company
2/2/2023Sam 1238Soups Company



The goal is to get unique company values for each date employee id on each date available. 

1 ACCEPTED SOLUTION
serpiva64
Solution Sage
Solution Sage

Hi,

you have to group by

serpiva64_0-1676584726345.png

Expand all rows

serpiva64_1-1676584754130.png

add 2 conditional columns

serpiva64_2-1676584786837.pngserpiva64_3-1676584804124.png

and finally filter all Yes

(you obtain the company in alphabetical order, if you want the first you have to add an index before)

You can take a look at the attached file

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

 

 

 

View solution in original post

2 REPLIES 2
serpiva64
Solution Sage
Solution Sage

Hi,

you have to group by

serpiva64_0-1676584726345.png

Expand all rows

serpiva64_1-1676584754130.png

add 2 conditional columns

serpiva64_2-1676584786837.pngserpiva64_3-1676584804124.png

and finally filter all Yes

(you obtain the company in alphabetical order, if you want the first you have to add an index before)

You can take a look at the attached file

If this post is useful to help you to solve your issue, consider giving the post a thumbs up and accepting it as a solution!

 

 

 

Its removing some of my dates, I need to keep all the dates but it seems when it encounters the same duration for the same date and with a different company  it removes the date completely. Please Help. Wondering if this is related to not adding the index, could you explain that step by step, thanks in advance.


Current Status

Employee IdCompanyDate Duration
123Chicken Company1/1/2023 4
123Box Company1/1/2023 4
321Box Company1/2/2023 8

 

Error  out of query:

Employee IdCompanyDateDuration
321Box Company1/2/2023  8

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.