Forum Discussion

homboy27's avatar
homboy27
Helper III
1 year ago
Solved

Summing by Client

Please see below 2 tables. I would like to bring in total sales from column B into Column A. However I do not want the total sales to be repeated if a client in table A has multiple rows. Is it possi...
  • v-kathullac's avatar
    v-kathullac
    1 year ago

    Hi homboy27,

    Thank you for reaching out to Microsoft Fabric Community Forum.

     

    can you try with this calculated column and let us know if you face any issues.this will pull total sales per client from Table B into Table A, but only show it once per client, on a specific row.

    TotalSales_Once = 
    VAR CurrentClient = TableA[Client]
    VAR CurrentLocation = TableA[Location]
    VAR IsFirstRow =
        TableA[Location] = 
            CALCULATE(
                MIN(TableA[Location]),
                FILTER(TableA, TableA[Client] = CurrentClient)
            )
    VAR TotalSales =
        CALCULATE(
            SUM(TableB[Sales]),
            FILTER(TableB, TableB[Client] = CurrentClient)
        )
    RETURN
        IF(IsFirstRow, TotalSales, 0)
    

     

    Regards,

    Chaithanya.