Forum Discussion
Matrix difference in total with grouping category
Hi JKG ,
Not certain what is the relationship between your another table and this sample table, please check whether you have enabled 'show item with no data' first.
Then I noticed that each total value is wrong when you add the type field to the matrix, based on my test sample, you can try to modify the measure like this:
m =
VAR x =
CALCULATE (
SUM ( 'Pilpt Payroll Detail'[Total_CHs_Paid] ),
FILTER (
ALL ( 'Pilpt Payroll Detail' ),
'Pilpt Payroll Detail'[BidMnth] < MAX ( 'Pilpt Payroll Detail'[BidMnth] )
&& 'Pilpt Payroll Detail'[PayCode] IN DISTINCT ( 'Pilpt Payroll Detail'[PayCode] )
)
)
VAR y =
CALCULATE (
SUM ( 'Pilpt Payroll Detail'[Total_CHs_Paid] ),
FILTER (
ALL ( 'Pilpt Payroll Detail' ),
'Pilpt Payroll Detail'[BidMnth] = MAX ( 'Pilpt Payroll Detail'[BidMnth] )
&& 'Pilpt Payroll Detail'[PayCode] IN DISTINCT ( 'Pilpt Payroll Detail'[PayCode] )
)
)
RETURN
IF (
HASONEFILTER ( 'Pilpt Payroll Detail'[BidMnth] ),
SUM ( 'Pilpt Payroll Detail'[Total_CHs_Paid] ),
IF ( ISINSCOPE ( 'Table'[Type] ), y - x, y - x )
)
Attached my sample file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I tried your solution and it is very close to working. The categories show up correctly, but now the total is picking up the difference of the category for the entire data set rather than for the filtered months.