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

Be 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

Reply
Anonymous
Not applicable

Need Help with Dax! Pull unique values based on two criterias

Hi everyone, I have a table with time entry data for employees. I am working on a overtime dashboard. At the end I will need to have Total Schedule Hours, Overtime Hours and Overtime % (Overtime Hours/Total Schedule Hours). For me to calculate the Total Schedule Hours I need to extract only the schedule hours for 1 day, but in some cases I have employees that type in multiple codes of time entries and every time they do that I get a line with the daily schedule hours but I only need to add 1 line, not all.

 

Example:

 

powerbisample.PNG

 

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

So your requirement is to remove the duplicate rows if the user enter the same rows in different times, right? If you want to show the data in any chart in power bi, you don't need to write DAX function because the visual in power bi will filter duplicate rows automatically. If not, the best way to solve this is to write a trigger or delete the duplicates in database, for example, in SQL you may refer to: https://www.geeksforgeeks.org/sql-remove-duplicates-without-distinct/.

 

In addtion, you can also do this in power query, click query editor-> Remove Rows-> Remove Duplicates.

Capture.PNG 

 

Regards,

Jimmy Tao

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous,

 

So your requirement is to remove the duplicate rows if the user enter the same rows in different times, right? If you want to show the data in any chart in power bi, you don't need to write DAX function because the visual in power bi will filter duplicate rows automatically. If not, the best way to solve this is to write a trigger or delete the duplicates in database, for example, in SQL you may refer to: https://www.geeksforgeeks.org/sql-remove-duplicates-without-distinct/.

 

In addtion, you can also do this in power query, click query editor-> Remove Rows-> Remove Duplicates.

Capture.PNG 

 

Regards,

Jimmy Tao

Greg_Deckler
Super User
Super User

You should be able to use DISTINCT or VALUES or maybe FIRSTNONBLANK with the right filters, etc. Or, just use SUMMARIZE with an AVERAGE or MAX or MIN.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

You should be able to use DISTINCT or VALUES or maybe FIRSTNONBLANK with the right filters, etc. Or, just use SUMMARIZE with an AVERAGE or MAX or MIN.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.