Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi, I tried lookupvalue and calculate but can't get the result I need. Any help is appreciated. Thanks!
Assigned = CALCULATE(FIRSTNONBLANK(Table[Assignee],1),FILTER(ALL(Table[Assignee]),Table[EndDate]=Table[AssigneeEndDate]))
Assigned =
VAR Key =
MIN(Table[ID])
VAR LatestStatusDate =
CALCULATE(
MAX(Table[EndDate]),
Table[ID] = Key
)
VAR LatestAssignee =
LOOKUPVALUE(
Table[Assignee],
Table[Key], Key,
Table[AssigneeEndDate], LatestStatusDate
)
RETURN
LatestAssignee
Table
ID | StartDate | EndDate | Status | AssigneeEndDate | Assignee |
1 | 9/1/2023 | 9/3/2023 | Start | null | null |
1 | 9/4/2023 | 9/5/2023 | In Progress | null | null |
1 | 9/6/2023 | null | Complete | null | null |
1 | null | null | null | 9/1/2023 | null |
1 | null | null | null | 9/3/2023 | A |
1 | null | null | null | 9/5/2023 | B |
1 | null | null | null | null | C |
Result
ID | StartDate | EndDate | Status | Assignee |
1 | 9/1/2023 | 9/3/2023 | Start | A |
1 | 9/4/2023 | 9/5/2023 | In Progress | B |
1 | 9/6/2023 | null | Complete | C |
Hi @AC2023 ,
Here are the steps you can follow:
1. Create measure.
Measure =
MAXX(
FILTER(ALL('Table'),
'Table'[EndDate] in SELECTCOLUMNS('Table',"1",[AssigneeEndDate])),[StartDate])
Measure 2 =
MAXX(
FILTER(ALL('Table'),
[Measure]=MAX('Table'[StartDate])),[Assignee])
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @v-yangliu-msft,
Thank you! This works great with the sample data I provided, and it gives the correct desired result. However, when I applied this to my actual table which is huge, I got the error message "Resources Exceeded. This visual has exceeded the available resources. Try filtering to decrease the amount of data displayed." Any ideas how to fix this error?
It looks like you want to assign the "Assignee" value to each row in your table based on certain conditions. To achieve this, you can use DAX measures and a combination of functions to perform the lookup and assignment. Here's a modified version of your DAX code to achieve the desired result:
Assigned =
VAR Key =
Table[ID]
VAR LatestStatusDate =
CALCULATE(
MAX(Table[EndDate]),
FILTER(Table, Table[ID] = Key)
)
VAR LatestAssignee =
CALCULATE(
MAX(Table[Assignee]),
FILTER(
Table,
Table[ID] = Key &&
Table[AssigneeEndDate] <= LatestStatusDate
)
)
RETURN
LatestAssignee
This code should assign the appropriate "Assignee" value to each row based on the conditions you specified. The key points in this code are:
When you use this measure in your table, it should give you the desired result, as shown in your "Result" section.
Thank you for the DAX code, but it's not returing the desired result.
This problem can easily done in SQL query using self left join.
Here's SQL query, the 1st select is the data from the table, the 2nd select is the correct desired result:
Note that in this sample data, I added the Type field to make it easy to get the correct result.
This is the result in Power BI:
DAX for Assigned:
I get the same result whether I've the extra filter on TempTable[Type] or not.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
20 | |
19 | |
13 | |
12 |
User | Count |
---|---|
41 | |
27 | |
23 | |
22 | |
22 |