Forum Discussion

RMV's avatar
RMV
Icon for Helper V rankHelper V
7 years ago
Solved

duplicating row until next date or today's date

Hi guys,   I need help to duplicate rows with some conditions: 1. each row is duplicated until next update date 2. if the latest update date is before today's date, that latest row is duplicated ...
  • AlB's avatar
    AlB
    7 years ago

    RMV 

    Try this:

    NewTable_V2 =
    GENERATE (
        Table1;
        GENERATESERIES (
            CALCULATE ( MIN ( Table1[Date] ) );
            VAR FirstDay_ =
                CALCULATE ( MIN ( Table1[Date] ) )
            VAR LastDay_ =
                CALCULATE (
                    MIN ( Table1[Date] );
                    FILTER ( ALL ( Table1[Date] ); Table1[Date] > FirstDay_ );
                    ALLEXCEPT ( Table1; Table1[Asset No.]; Table1[Type]; Table1[Capacity] )
                )
            RETURN
                IF ( ISBLANK ( LastDay_ ); TODAY (); LastDay_ - 1 )
        )
    )
    

    It fills up the last one up to today as you described initially. The new date column will be shown as "Value" and the old Date column is shown as well. You can use SELECTCOLUMNS to remove the old one and change the name of the new one.

     

    Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

    Cheers  Datanaut