Forum Discussion

Quynhtran's avatar
Quynhtran
Regular Visitor
5 years ago
Solved

Return values from conditional column within each group

Hello everybody,

 

I would like to create new column [Name Revised], which updates the correct name for each ID. For example, if there are in the same ID, the correct name is the name that have the earliest date. 

 

NameDateValueIDName Revised
A12/1/202110123456A
B12/3/2021-10123456A
C12/1/202120123789C
D12/5/2021-20123789C

 

I have tried many approaches but they still doesnt work (TOPN, FIRSTNONBLANK, creating summarize table then LOOKUPVALUES, ..). 

 

Should you have any idea to solve this issue, please share with me.

 

Many Thanks.

Quynh Tran.

  •  

    Name Revised CC =
    VAR _currentID = Data[ID]
    VAR _mindate =
    CALCULATE ( MIN ( Data[Date] ), FILTER ( Data, Data[ID] = _currentID ) )
    RETURN
    CALCULATE (
    DISTINCT ( Data[Name] ),
    FILTER ( Data, Data[ID] = _currentID && Data[Date] = _mindate )
    )

     

     

    Link to the pbix file 

     

     

2 Replies

  •  

    Name Revised CC =
    VAR _currentID = Data[ID]
    VAR _mindate =
    CALCULATE ( MIN ( Data[Date] ), FILTER ( Data, Data[ID] = _currentID ) )
    RETURN
    CALCULATE (
    DISTINCT ( Data[Name] ),
    FILTER ( Data, Data[ID] = _currentID && Data[Date] = _mindate )
    )

     

     

    Link to the pbix file