Forum Discussion
powerbi_9
7 years agoFrequent Visitor
Lookup value for date with 31 days
Hi, I am fairly new to Power BI and trying to understand the DAX funtions. I am struck with the below. Any help is appreciated. The request is to get the first status based on the start date ...
- 7 years ago
Hi powerbi_9
You may refer to below dax to create the calculated columns and link the two table in relationship view.
date_outcome = CALCULATE ( FIRSTNONBLANK ( Table2[StartDate], 1 ), FILTER ( Table2, Table2[StartDate] >= Table1[StartDate] && Table2[ParentID] = Table1[ParentID] && Table2[StartDate] < Table1[StartDate] + 31 ) )Status_lookup = CALCULATE ( FIRSTNONBLANK ( Table2[Status], 1 ), TOPN ( 1, FILTER ( Table2, Table2[StartDate] = Table1[date_outcome] && Table2[ParentID] = Table1[ParentID] ), Table2[ChildID], ASC ) )Regards,
Cherie
powerbi_9
7 years agoFrequent Visitor
Also, it is possible that both datasets may have the duplicate parent id's.
- v-cherch-msft7 years ago
Microsoft Employee
Hi powerbi_9
You may refer to below dax to create the calculated columns and link the two table in relationship view.
date_outcome = CALCULATE ( FIRSTNONBLANK ( Table2[StartDate], 1 ), FILTER ( Table2, Table2[StartDate] >= Table1[StartDate] && Table2[ParentID] = Table1[ParentID] && Table2[StartDate] < Table1[StartDate] + 31 ) )Status_lookup = CALCULATE ( FIRSTNONBLANK ( Table2[Status], 1 ), TOPN ( 1, FILTER ( Table2, Table2[StartDate] = Table1[date_outcome] && Table2[ParentID] = Table1[ParentID] ), Table2[ChildID], ASC ) )Regards,
Cherie
- powerbi_97 years agoFrequent Visitor
Worked perfectly. Thank you!