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
pierre415
Helper I
Helper I

Filter column values based on 2 other columns

19885920_1441659535925600_796141086_o[1].jpg

 

Hey folks,

I'm trying to create a column like the one to the right in the picture, where every line is a project and I need to add up everyone's work days YTD. If say, two projects have the same month and same person then only one would need to count to the YTD workdays. Any idea how to do this? 

Thanks,

Pierre

2 ACCEPTED SOLUTIONS
prakash_gautam
Resolver II
Resolver II

Hello Pierre,

 

There could be better method but this DAX also works if you have a unique field the data set:

 

 

Distinct WD =
IF (
CALCULATE (
COUNTROWS ( Table1 ),
ALLEXCEPT ( Table1, Table1[Name], Table1[Date] ),
EARLIER ( Table1[Id] ) >= Table1[Id]
)
= 1,
[This Month],
0
)

 

distinct.png

Thanks,
Prakash

View solution in original post

Hello Pierre,

 

The AllEXCEPT gives the all rows of the table (for each Name and Date pair) and earlier gives the current row.
When we count all Id where Name and Date is equal AND current Id is >= all Id, we are left with the correct count.

 

The >= might be confusing. Please see below MSDN link where earlier has been described in detail:


https://msdn.microsoft.com/en-us/library/ee634551.aspx

 

Thanks,
Prakash

View solution in original post

5 REPLIES 5
prakash_gautam
Resolver II
Resolver II

Hello Pierre,

 

There could be better method but this DAX also works if you have a unique field the data set:

 

 

Distinct WD =
IF (
CALCULATE (
COUNTROWS ( Table1 ),
ALLEXCEPT ( Table1, Table1[Name], Table1[Date] ),
EARLIER ( Table1[Id] ) >= Table1[Id]
)
= 1,
[This Month],
0
)

 

distinct.png

Thanks,
Prakash

Hey Prakash could you explain to me how the Earlier function works in this scenario?

 

Thanks,

Pierre

Hello Pierre,

 

The AllEXCEPT gives the all rows of the table (for each Name and Date pair) and earlier gives the current row.
When we count all Id where Name and Date is equal AND current Id is >= all Id, we are left with the correct count.

 

The >= might be confusing. Please see below MSDN link where earlier has been described in detail:


https://msdn.microsoft.com/en-us/library/ee634551.aspx

 

Thanks,
Prakash

Awesome thanks Prakash!

Thanks man you're a legend

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.