Forum Discussion

anshgupta's avatar
anshgupta
Frequent Visitor
3 years ago
Solved

Add rows based on a column's first value

Hi,   I have a table in the form: Week Total 44 123 45 245 46 456   I want to add 3 rows in the table containing the last three weeks before week 44 shown in the first row abo...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi anshgupta ,

    Please try below steps:

    1. below is my test table

    Table:

    2. create a new table with below dax formula

    Table 2 =
    VAR min_val =
        MINX ( ALL ( 'Table' ), [Week] )
    VAR _a = min_val - 1
    VAR _b = min_val - 2
    VAR _c = min_val - 3
    RETURN
        { ( _a, "" ), ( _b, "" ), ( _c, "" ) }
    

    3. create a new table with below dax formual

    Table 3 = UNION('Table','Table 2')

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_ Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.