Forum Discussion

jasonyeung87's avatar
jasonyeung87
Helper V
1 year ago
Solved

Total in table visualization not being calculated when it depends on row date

Hi,   I currently have a table visualization that displays timesheet data. It looks similar to:   Each row is a timesheet record for a period of time. I'm trying to obtain the sums of the V...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi jasonyeung87 ,

    Thank you for reaching out to the Microsoft Fabric Community. Also thankyou pankajnamekar25  for your input.

     

    you're correct, the issue occurs because the Total row lacks row context, so the original measure sums vacation hours across the entire dataset instead of the visible date range.

    To fix this, here's a revised measure that:

    • Calculates vacation per week as before and dynamically uses the min and max visible dates for the Total row.
    Vacation Hours (with Correct Total) :=
    VAR IsTotal = NOT HASONEVALUE('Timesheet'[Timesheet ID])
    VAR StartDate = MIN('Timesheet'[Week Start Date])
    VAR EndDate = MAX('Timesheet'[Week End Date])
    
    RETURN
    IF (
        IsTotal,
        CALCULATE(
            SUM('Time-Off Split'[Krow__Hours__c]),
            'Time-Off Split'[Krow__Date__c] >= StartDate,
            'Time-Off Split'[Krow__Date__c] <= EndDate,
            RELATED('Time Off'[Krow__Type__c]) = "Vacation",
            'Time-Off Split'[IsDeleted] = FALSE()
        ),
        CALCULATE(
            SUM('Time-Off Split'[Krow__Hours__c]),
            FILTER (
                'Time-Off Split',
                'Time-Off Split'[Krow__Date__c] >= SELECTEDVALUE('Timesheet'[Week Start Date]) &&
                'Time-Off Split'[Krow__Date__c] <= SELECTEDVALUE('Timesheet'[Week End Date]) &&
                RELATED('Time Off'[Krow__Type__c]) = "Vacation" &&
                'Time-Off Split'[IsDeleted] = FALSE()
            )
        )
    )
    

    This should now reflect correct totals based only on the weeks shown in your table.

     

    Hope this helps. Please reach out for further assistance.

    If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.

     

    Thank you.