Forum Discussion

PowerMyBI's avatar
PowerMyBI
Icon for Helper I rankHelper I
6 years ago
Solved

Calculate sum by date and type

Hi Power BI community,   I am trying to calculate the sum of units recorded each day by staff member. Effectively I have many columns of transaction data pulled from our practice management platfor...
  • edhans's avatar
    edhans
    6 years ago

    Great PowerMyBI - Glad you got it figured out. I misunderstood your original request. For grins I went back and revised my measure and this returns the same. Be sure to mark one as the solution so this thread can be marked as solved.

     

    Total 2 =
    VAR varCurrentName =
        MAX( 'Table'[StaffName] )
    VAR varCurrentDate =
        MAX( 'Table'[Date] )
    VAR Result =
        CALCULATE(
            SUM( 'Table'[Units] ),
            FILTER(
                ALL(
                    'Table'[Date],
                    'Table'[StaffName],
                    'Table'[Units]
                ),
                'Table'[Date] = varCurrentDate
                    && 'Table'[StaffName] = varCurrentName
            )
        )
    RETURN
        Result