Forum Discussion

Drors's avatar
Drors
Resolver III
8 years ago
Solved

Duplicate rows with new values

Hi,

 

I have a table like that :  Customer|Date|amount

 

I need to duplicate each row 12 times each time with the next month 

example:

original row

customer   |   Date    | amount

1                | 1/1/17   | 100

 

I need it to be like : 

customer   |   Date    | amount

1                | 1/1/17   | 100

1                | 1/2/17   | 100

1                | 1/3/17   | 100

1                | 1/4/17   | 100

 

Is it possible to do it with power bi?

 

Thanks,

 

  • Hi Drors

     

    Try this solution

     

    Go to Modelling Tab>>> New Table

     

    New Table =
    GENERATE (
        TableName,
        VAR mymonth = MONTH ( TableName[Date] ) RETURN GENERATESERIES ( 0, 11, 1 )
    )

    Now Add this CALCULATED COLUMN to your NEW TABLE

     

    New date =
    DATE ( YEAR ( 'New Table'[Date] ), MONTH ( 'New Table'[Date] ) + 'New Table'[Value], DAY ( 'New Table'[Date] ) )

9 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Hi Drors

     

    Try this solution

     

    Go to Modelling Tab>>> New Table

     

    New Table =
    GENERATE (
        TableName,
        VAR mymonth = MONTH ( TableName[Date] ) RETURN GENERATESERIES ( 0, 11, 1 )
    )

    Now Add this CALCULATED COLUMN to your NEW TABLE

     

    New date =
    DATE ( YEAR ( 'New Table'[Date] ), MONTH ( 'New Table'[Date] ) + 'New Table'[Value], DAY ( 'New Table'[Date] ) )