Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi All,
I have a table of history data (one row per event) that looks like:
The _primarykey here is actually that of a parent table, not the history table... the parent item can have multiple rows in the history table.
What I'm looking for is the DAX to populate the "Renewed" column, based on finding another row (for the same parent primary key) that has a 'Start Date' that matches the 'End Date' of the current row.
I've tried the following as a calculated column, but i get a syntax error:
Renewed =
VAR vkey = history[_primarykey]
VAR vdate = history[End Date]
RETURN
IF (
COUNTROWS (
FILTER (
FILTER ( FILTER ( history, ALL ), history[_primarykey] = vkey ),
history[Start Date] = vdate
)
)
> 0,
"Yes",
"No"
)
The logic being to expand the table to ALL rows, then filter back down to match the (parent) primary key, and then the dates, and to count the rows of that table... if the count is greater than zero then 'Renewed' = "Yes".
All help appreciated.
Solved! Go to Solution.
@Anonymous
This Column should work as well
Renewed =
VAR myenddate = Table1[End Date]
RETURN
IF (
CONTAINS (
FILTER ( Table1, Table1[_primarykey] = EARLIER ( Table1[_primarykey] ) ),
Table1[Start Date], myenddate
),
"Yes",
"No"
)
Why not just:
Renewed Column = IF([EndDate] IN ALL(Matches[StartDate]),"Yes","No")
Hi @Greg_Deckler... well I tried to do it with table filters and counts because I hadn't yet come across the IN operator...
The solution suggested doesn't take into account the match on the parent _primarykey also though... I need to match two items between the rows. Does IN handle multiple columns?
OK, try this then:
Renewed = IF([EndDate] IN FILTER(ALL(Matches[StartDate]),[_primarykey]=EARLIER([_primarykey])),"Yes","No")
@Anonymous
This Column should work as well
Renewed =
VAR myenddate = Table1[End Date]
RETURN
IF (
CONTAINS (
FILTER ( Table1, Table1[_primarykey] = EARLIER ( Table1[_primarykey] ) ),
Table1[Start Date], myenddate
),
"Yes",
"No"
)
@Anonymous
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 71 | |
| 50 | |
| 46 | |
| 44 |