Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Create a column based on the value in same row or different row

I have below table, I want to create a new column that shows the default integration for the ID. i.e NewColumn below

 

If the there is Default_Flag = 1 for then use the Integration value from that row and fill the Newcolumn with that value in all rows for that ID

 

i.e for ID 001 first row has the default_Flag = 1 so will use value "A" from integrations column and fill in NewColumn for all the rows for 001 with "A"

 

ID 003 doesnt have any rows with default_Flag = 1 so will fill NewColumn as "No Default"

 

How do I do it?

 

ID   Integration         Default_Flag        NewColumn      
001A1A
001C0A
001B0A
002B1B
002D0B
003A0No Default
003B0No Default

 

Thanks

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Anonymous Not sure I quite follow the rules on how to arrive at the values.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your response Greg_Deckler 

       

      I have updated the question, let me know if that helps

  • TheoC's avatar
    TheoC
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    Here is a quick calcualted column that will give you what you're after!

     

    Calculated Column = 

    VAR _1 = MAXX ( FILTER ( 'Table' , 'Table'[ID] = EARLIER ('Table'[ID] ) && 'Table'[Default Flag] = "1" ) , 'Table'[Integration] )

    RETURN

    IF ( ISBLANK ( _1 ) , "No Default" , _1 )

    Output is as per below:

    Hope this helps!

    Theo 🙂