Forum Discussion

eduardosilvin3's avatar
2 years ago

Add new calculated rows in matrix

Hello all, I have this calc table, comes from a table where I have in the same rows "sales" and "costs".... so this was to get all the rows and add it in the same column, now I have all as I need in the matrix as a financial statemant but I need to add more rows with new calculations, like "item net value - item_Total cost"

 

Any ideas?

 

 

 

 

6 Replies

    • eduardosilvin3's avatar
      eduardosilvin3
      Helper II

      thanks for the answer, but I did not get how to replicate your file into my file

      • Ahmedx's avatar
        Ahmedx
        Super User

        Can you please share your demo input and expected output!

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi eduardosilvin3 

     

    Since you need to add more rows with new calculations in the matrix, you may need to make those calculations in advance and union the results to your current calculated values. Then use data from the new table into the matrix. An example: 

    new table =
    VAR _table1 =
        SUMMARIZE (
            'DB Sales',
            'DB Sales'[Index],
            'DB Sales'[invoice_no],
            'DB Sales'[invoice_date],
            "new column 1", SUM ( 'DB Sales'[item_net_value] ),
            "new column 2", SUM ( 'DB Sales'[Sub Revenue] )
        )
    VAR _table2 =
        SUMMARIZE (
            'DB Sales',
            'DB Sales'[Index],
            'DB Sales'[invoice_no],
            'DB Sales'[invoice_date],
            "new column 1", SUM ( 'DB Sales'[item_TotalCost] ),
            "new column 2", SUM ( 'DB Sales'[Sub Cost] )
        )
    VAR _table3 =
        SUMMARIZE (
            'DB Sales',
            'DB Sales'[Index],
            'DB Sales'[invoice_no],
            'DB Sales'[invoice_date],
            "new column 1", SUM ( 'DB Sales'[item_net_value] ) - SUM ( 'DB Sales'[item_TotalCost] ),
            "new column 2", ..........
        )
    RETURN
        UNION ( _table1, _table2, _table3 )

     

    Best Regards,
    Jing
    If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!