Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have a table like below.
| Code | CompletedDate | ProductDetail |
| 1 | 1/01/2018 | A |
| 1 | 1/04/2019 | B |
| 1 | 23/05/2021 | C |
| 2 | 9/02/2018 | D |
| 2 | 5/05/2021 | C |
| 2 | 6/05/2022 | A |
| 3 | 1/01/2018 | K |
| 3 | 10/05/2019 | B |
| 3 | 30/06/2021 | C |
| 3 | 1/01/2024 | L |
| 4 | 6/06/2017 | B |
| 4 | 9/03/2018 | J |
| 4 | 5/05/2021 | C |
| 4 | 3/03/2024 | D |
I need to create a Target column based on CompletedDate for Each Code group. So the expected solution would be like below.
| Code | CompletedDate | ProductDetail | Target |
| 1 | 1/01/2018 | A | B |
| 1 | 1/04/2019 | B | C |
| 1 | 23/05/2021 | C | |
| 2 | 9/02/2018 | D | C |
| 2 | 5/05/2021 | C | A |
| 2 | 6/05/2022 | A | |
| 3 | 1/01/2018 | K | B |
| 3 | 10/05/2019 | B | C |
| 3 | 30/06/2021 | C | L |
| 3 | 1/01/2024 | L | |
| 4 | 6/06/2017 | B | J |
| 4 | 9/03/2018 | J | C |
| 4 | 5/05/2021 | C | D |
| 4 | 3/03/2024 | D |
I tried the below DAX code. It generates correct results for some but not all. Can someone please help me. Thanks.
| Code | CompletedDate | ProductDetail | Target |
| 1 | 1/01/2018 | A | B |
| 1 | 1/04/2019 | B | C |
| 1 | 23/05/2021 | C | |
| 2 | 9/02/2018 | D | A |
| 2 | 5/05/2021 | C | A |
| 2 | 6/05/2022 | A | |
| 3 | 1/01/2018 | K | B |
| 3 | 10/05/2019 | B | C |
| 3 | 30/06/2021 | C | L |
| 3 | 1/01/2024 | L | |
| 4 | 6/06/2017 | B | C |
| 4 | 9/03/2018 | J | C |
| 4 | 5/05/2021 | C | D |
| 4 | 3/03/2024 | D |
Solved! Go to Solution.
hello @luckygirl
please check if this accomodate your need.
create a new calculated column with following DAX
Target =
var _Min =
MINX(
FILTER(
'Table',
'Table'[CompletedDate]>EARLIER('Table'[CompletedDate])&&
'Table'[Code]=EARLIER('Table'[Code])
),
'Table'[CompletedDate]
)
Return
MINX(
FILTER(
'Table',
'Table'[CompletedDate]=_Min
),
'Table'[ProductDetail]
)
hello @luckygirl
please check if this accomodate your need.
create a new calculated column with following DAX
Target =
var _Min =
MINX(
FILTER(
'Table',
'Table'[CompletedDate]>EARLIER('Table'[CompletedDate])&&
'Table'[Code]=EARLIER('Table'[Code])
),
'Table'[CompletedDate]
)
Return
MINX(
FILTER(
'Table',
'Table'[CompletedDate]=_Min
),
'Table'[ProductDetail]
)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 11 | |
| 6 | |
| 5 |