Reply
SACooper
Helper II
Helper II
Partially syndicated - Outbound

Dax Measure on Matrix not giving expected totals

SACooper_0-1661241400433.png

I am planning to turn the above matrix into a sort of heat map - eventually i'll remove the [KPI_Target] value and use that for conditional formatting - however at present the total for [KPI_Target] is wrong - is should be 134 (45+44+45)

 

[KPI_Target] is a measure: [Days In View] * [Daily Target] * [Number of Staff]

[Days In View]DISTINCTCOUNT(CompletedItems[ProcessedDate])

[Number of Staff]COUNTROWS(VALUES(CompletedItems[ProcessedBy]))

 

[Daily Target]  = 

VAR _testTime = IF(NOT(ISBLANK([Daily Work Time formatted])),[Daily Work Time formatted], "00:00:00")
VAR _hourMarker = FIND(":", _testTime, 1)
VAR _hours = LEFT(_testTime, _hourMarker -1)
VAR _totalDays = ROUNDDOWN(_hours / 24,0)
VAR _remainingHours = _hours - (_totalDays * 24)
VAR _minuteMarker = FIND(":", _testTime, _hourMarker + 1)
VAR _minutes = RIGHT(LEFT(_testTime, _minuteMarker-1), 2)
VAR _seconds = RIGHT(_testTime, 2)
VAR _decimalTime = ((_totalDays * 24 * 60 * 60) + (_remainingHours * 60 * 60) + (_minutes * 60) + _seconds) / (1 * 24 * 60 * 60)
VAR _dayValue = Value("07:15:00")

RETURN

ROUNDDOWN(([Target_IPD] / _dayValue) * _decimalTime,0)

 

[Target_IPD] = 43

[Daily Work Time formatted]

Daily Work Time formatted =
VAR _flexitime = SUM('flexi_FullReport'[Day_TotalTime])
VAR _hours = IF(LEN(_flexitime) = 0,BLANK(), FORMAT(ROUNDDOWN(_flexitime / 60,0),"00"))
VAR _rem_minutes = IF(LEN(_flexitime) =0,BLANK(), FORMAT(_flexitime - (_hours * 60), "00"))
VAR _seconds = FORMAT(0,"00")
VAR _result = IF(AND(ISBLANK(_hours), ISBLANK(_rem_minutes)), BLANK(), _hours & ":" & _rem_minutes & ":" & _seconds)
RETURN
_result
 

In the above example:

[Days In View]  = 1

[Number of Staff] = 1 (per row) and 3 for the total

[Daily Target]  is correct per row as is the [KPI_Target] 

 
(I verfied these by adding cards and filtering and by adding the measures to the matrix.)
I'm pretty sure i've dropped the ball somewhere within these measures but after a couple of days i'm not getting much closer to an answer.
1 ACCEPTED SOLUTION

Syndicated - Outbound

for example take first two rows from you pictures

for row KPI_Target=45 suppose you have data table 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205

 

so [Days In View] =6 and [Number of Staff] = 5 

 

for row KPI_Target=44 suppose you have data table 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20207
06.01.20205
01.01.20201
02.01.20208
03.01.20201
04.01.20202
05.01.20204

so [Days In View] =6 and [Number of Staff] = 6

 

but for total row same data table look like 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205
05.01.20207
02.01.20208

 

so [Days In View] =6 and [Number of Staff] = 8

 

 

I hope this ex[planation will help you for understand 

View solution in original post

5 REPLIES 5
SolomonovAnton
Solution Sage
Solution Sage

Syndicated - Outbound

hello ! 

 

reason why your total [KPI_Target] incorrect  is using DISTINCTCOUNT and VALUES in measures [Daily Target]  &  [Number of Staff]

Syndicated - Outbound

what should it be?

Syndicated - Outbound

for example take first two rows from you pictures

for row KPI_Target=45 suppose you have data table 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205

 

so [Days In View] =6 and [Number of Staff] = 5 

 

for row KPI_Target=44 suppose you have data table 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20207
06.01.20205
01.01.20201
02.01.20208
03.01.20201
04.01.20202
05.01.20204

so [Days In View] =6 and [Number of Staff] = 6

 

but for total row same data table look like 

ProcessedDateProcessedBy
01.01.20201
02.01.20202
03.01.20201
04.01.20202
05.01.20204
06.01.20205
05.01.20207
02.01.20208

 

so [Days In View] =6 and [Number of Staff] = 8

 

 

I hope this ex[planation will help you for understand 

Syndicated - Outbound

Think its slowly sinking in i've recreated those two measures as variables as:

VAR _daysInView = COUNTROWS(VALUES(CompletedItems[ProcessedDate]))
VAR _numberOfStaff = COUNTROWS(VALUES(CompletedItems[ProcessedBy]))
 
EDIT:  Think its just me over complicating things 
 
Which now provide the correct total figures -- thinks just go massively sideways when I re-incorporate the daily target.

Syndicated - Outbound
VAR _daysInView = COUNTROWS(VALUES(CIVICA_CompletedItems[ProcessedDate]))
VAR _numberOfStaff = COUNTROWS(VALUES(CIVICA_CompletedItems[ProcessedBy]))
--
VAR _flexitime = SUM('flexi UD_FullReport'[Day_TotalTime])
VAR _decimalHours = _flexitime / 60
VAR _dayValue = TIME(7,15,0) * 24
VAR _targetPerHour = _dayValue / [Target_IPD]

RETURN ROUNDDOWN(_decimalHours / _targetPerHour,0)
avatar user

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)