Forum Discussion

jacko11's avatar
jacko11
Frequent Visitor
4 years ago
Solved

Combining two columns after the latest value

Hello,

 

I have two columns and I want to combine these two columns after the latest value. Could you please help me?

 

Example:

 

Date Column AColumn BCombined Column A and B
2022-01-01

100

nullnull
2022-01-02150nullnull
2022-01-03150nullnull
2022-01-04250750750
2022-01-05200 200
2022-01-0650 50
  • This calculates the max date of column B and then uses it till it gets to the date and then to A. Snippet and sample file is also attached.

    A+B =
    VAR MaxDateB =
        CALCULATE (
            MAX ( 'Table'[Date] ),
            FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[B] ) ) )
        )
    RETURN
        IF ( 'Table'[Date] <= MaxDateB, 'Table'[B], 'Table'[A] )
    

     

     

4 Replies

  • moizsherwani's avatar
    moizsherwani
    Icon for Continued Contributor rankContinued Contributor

    Hi jacko11 

     

    It isn't clear what you mean by combine the two column after the latest value? From the snippet example it seems like you are taking Column B as a priority and then when there is nothing in column B then you take column A, is this correct?

     

    If that is the case you would simple do something like 

     

    Combined Column A and B = If(NOT(ISBLANK(Column B)),Column B, Column A)

     

     

  • jacko11's avatar
    jacko11
    Frequent Visitor

    Hi moizsherwani,

     

    Thank you for your answer.

     

    I meant till to the last value on column B, it should get the values from column B which 750 in the example, then column A.

    • moizsherwani's avatar
      moizsherwani
      Icon for Continued Contributor rankContinued Contributor

      This calculates the max date of column B and then uses it till it gets to the date and then to A. Snippet and sample file is also attached.

      A+B =
      VAR MaxDateB =
          CALCULATE (
              MAX ( 'Table'[Date] ),
              FILTER ( 'Table', NOT ( ISBLANK ( 'Table'[B] ) ) )
          )
      RETURN
          IF ( 'Table'[Date] <= MaxDateB, 'Table'[B], 'Table'[A] )