Forum Discussion
Column Grand Total in Matrix is wrong
- 7 months ago
Hi ArchStanton , you can try these steps to get the desired result
You need two different logics:
One for monthly cells
One for totals
Replace your measure with this :DAX YTD New Cases := IF ( ISINSCOPE ( 'Date'[Month] ), -- Row level (month) TOTALYTD ( COUNT ( 'Cases'[Case Number] ), 'Cases'[Created On] ), -- Total level SUMX ( VALUES ( 'Date'[Month] ), TOTALYTD ( COUNT ( 'Cases'[Case Number] ), 'Cases'[Created On] ) ) )What this does
When a Month is in scope β normal YTD logic
When Month is NOT in scope (Grand Total):
Iterates each visible month
Calculates YTD per month
Sums those values
Alternative , If you have a proper Date dimensionDAX YTD New Cases := CALCULATE ( COUNT ( 'Cases'[Case Number] ), DATESYTD ( 'Date'[Date] ) )And apply the same ISINSCOPE total fix if needed.
βHope this solution helps you make the most of Power BI! If it did, click 'Mark as Solution' to help others find the right answers.
π‘Found it helpful? Show some love with kudos π as your support keeps our community thriving!
πLetβs keep building smarter, data-driven solutions together!π [Explore More]
1. Define a cutoff date
VAR CutoffDate =
DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
2. Apply the cutoff inside CALCULATE
YTD New Cases (Exclude Current Month) =
VAR CutoffDate =
DATE(YEAR(TODAY()), MONTH(TODAY()), 1)
RETURN
IF(
ISINSCOPE(Date2[Mth]),
-- Month rows
CALCULATE(
TOTALYTD(
COUNT('Cases'[Case Number]),
'Cases'[Created On]
),
'Cases'[Created On] < CutoffDate
),
-- Matrix Total
SUMX(
VALUES(Date2[Mth]),
CALCULATE(
TOTALYTD(
COUNT('Cases'[Case Number]),
'Cases'[Created On]
),
'Cases'[Created On] < CutoffDate
)
)
)
Many thanks for all of your help!