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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.


@ 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!:
The Definitive Guide to Power Query (M)

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.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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