Forum Discussion
Total in table visualization not being calculated when it depends on row date
- Anonymous1 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.
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.
Hi Anonymous and pankajnamekar25 ,
Thanks for your help! I tried it, made some minor changes (e.g. wanted to display "0.00" instead of a blank if there is no sum) and it worked!
The final version I used is below; it's almost identical to the one you mentioned.
Sum Time-Off Split Hours Vacation =
VAR IsTotal = NOT HASONEVALUE('Timesheet'[Id])
VAR StartDate = MIN('Timesheet'[Week Start Date])
VAR EndDate = MAX('Timesheet'[Week End Date])
RETURN
COALESCE(
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()
SUM('Time-Off Split'[Krow__Hours__c]),
FILTER (
'Time-Off Split',
'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()
)
)
),
0
)
Jason