cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

Filter column values based on 2 other columns

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
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
)

Thanks,
Prakash

Resolver II

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:

Thanks,
Prakash

5 REPLIES 5
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
)

Thanks,
Prakash

Helper I

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

Thanks,

Pierre

Resolver II

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:

Thanks,
Prakash

Helper I

Awesome thanks Prakash!

Helper I

Thanks man you're a legend

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

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

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors