Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Calculated Column Based on 4 Columns

Hello,

 

I have the following table,

 

office Nameuser IDUser Statususer Activated on
O1U1Completed20-Sep
O1U2In Progress19-Sep
O1U3Completed18-Sep
O1U4New 
O2U5Completed15-Sep
O2U6In Progress14-Sep
O2U7New 
O3U8In Progress14-Sep
O3U9New 

 

I want to calculate a column called USER such that table looks like this,

 

office Nameuser IDUser Statususer Activated onUSER
O1U1Completed20-SepU3
O1U2In Progress19-SepU3
O1U3Completed18-SepU3
O1U4New U3
O2U5Completed15-SepU5
O2U6In Progress14-SepU5
O2U7New U5
O3U8In Progress14-Sep 
O3U9New  

 

The User Column is nothing but the User ID in each office having user status as "Completed" and having the earliest user activated date.

 

For Example, for O1 --> U1 and U3 are in completed status, but U3 has activated earlier than U1 that is on 18th sept. So calculated column user should have value as U3.

For O2, the only user who has completed status is U5 so user will have U5

for O3, nobody has the completed status so it remains empty.

 

Please help me with DAX query

Ashish_Mathur 

 

 

Thanks, 

Dharani

 

 

  • Anonymous Maybe:

    USER Column =
      VAR __Office = [office Name]
      VAR __Table = FILTER('Table',[office Name] = __Office && [User Status] = "Completed")
      VAR __Min = MINX(__Table,[User Activated on])
    RETURN
      MAXX(FILTER(__Table,[User Activated On] = __Min),[user])

2 Replies

  • Hi,

    This calculated column formula works

    =LOOKUPVALUE(Data[user ID],Data[user Activated on],CALCULATE(MIN(Data[user Activated on]),FILTER(Data,Data[office Name]=EARLIER(Data[office Name])&&Data[User Status]="Completed")),Data[office Name],Data[office Name])

    Hope this helps.

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Maybe:

    USER Column =
      VAR __Office = [office Name]
      VAR __Table = FILTER('Table',[office Name] = __Office && [User Status] = "Completed")
      VAR __Min = MINX(__Table,[User Activated on])
    RETURN
      MAXX(FILTER(__Table,[User Activated On] = __Min),[user])