Search code examples
powerbidaxpowerbi-desktop

Power BI - Need DAX or any function to calculate data


This is my table Table

i need sum of all totalworkhours which is 780 in new column 'Nume' where date is 11-nov-23 and sum of all totalworkhours which is 200 in new column 'nume' where date is 12-nov-23 in each row. answer should look like below table. Output needed

this is what i tried to calculate sumx(filter(MarginReport,MarginReport[WkSTDate]=MarginReport[WkSTDate]),MarginReport[TotalWorkHours])

but its not working


Solution

  • I think you can solve your problem by creating Custom Column nume like this:

    nume = CALCULATE(
        SUM('Table'[TotalWorkHours]), 
        ALLEXCEPT('Table', 'Table'[WkSTDate])
    )
    

    ALLEXCEPT removes all context filters in the table except filters that have been applied to the specified columns. So, whenever any column but WkSTDate from your table is used, the formula will remove any slicer filters, providing a value equal to the sum of TotalWorkHours. When the data is sliced on WkSTDate, a filter will be applied at the row level.