Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Title: Rolling 12-Month or YTD Case Count Is Correct Overall, But Monthly Breakdown Shows Wrong Values
Hello everyone,
I’m facing the following issue in Power BI/DAX and would appreciate your help:
When I add Month to a matrix or table:
I want to count only those cases whose rolling or YTD total is greater than zero.
CaseCount_Positive =
COUNTROWS(
FILTER(
ADDCOLUMNS(
VALUES( Table_Cases[CaseID] ),
"MonthlyOrYTDTotal",
CALCULATE(
SUM( Table_Cases[Value] ),
Table_Metrics[MetricCode] = "KPI",
Table_Cases[Value] <> 0,
IF(
ISCROSSFILTERED( Table_Org ),
TRUE(),
Table_Org[OrgCode] <> "Org"
)
)
),
[MonthlyOrYTDTotal] <> 0
)
)
It seems the combination of my DAX measure with the calculation group isn’t filtering properly at the single-month level.
The Sum of the KPI is having the correct value for total and on month.
Thank you for any insights, example DAX snippets, or explanations!
Best regards,
Hi @ThisIsBlecki,
Thank you for reaching out to the Microsoft fabric community forum.
The total count looks correct because it evaluates the entire dataset. But when you break it down by month, the DAX measure might not be using each row’s date correctly. As a result, it applies the same total across all months making them look identical.
Use something like MAX(DimDate[Date]) to grab the specific date for each row in your visual. Then plug that into DATESINPERIOD or TOTALYTD, so your measure recalculates based on the correct month.
Keep your base KPIs clean and reusable, and always use the current row’s date in your time filters. If using calculation groups, be extra careful they can change filter context unexpectedly, so anchor your dates explicitly.
Rolling Distinct Cases (Filtered) :=
VAR CurrentMonth =
MAX(DimDate[Date]) -- Gets the current row-level month in visual
RETURN
CALCULATE(
COUNTROWS(
FILTER(
VALUES(FactTable[CaseID]),
CALCULATE(
SUM(FactTable[Value]),
FactTable[IndicatorCode] = "SOME_INDICATOR",
FactTable[OrgCode] = "SomeOrg",
DATESINPERIOD(
DimDate[Date],
CurrentMonth,
-12,
MONTH
)
) > 0
)
)
)
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it
Best Regards,
Harshitha.
Community Support Team
Hi @ThisIsBlecki ,
Just wanted to check if you had the opportunity to review the suggestion provided?
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You.
Harshitha.
Community Support Team.
Hi @ThisIsBlecki ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please Accept it as a solution so that other community members can find it easily.
Thank You.
Harshitha.
Community Support Team.
Hi @ThisIsBlecki,
May I ask if you have resolved this issue? If so, please mark the helpful reply and Accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank You.
Harshitha.
Community Support Team.
Hi @v-hjannapu ,
Unfortunately, it didn’t work. Power BI applies a strange time filter that I can’t make sense of. Unfortunately, I can’t find a solution without Tabular Editor and DAX Studio.
I’ve moved the entire calculation logic to the data warehouse.
Thanks for your help, and sorry for the late reply — I was away.
Hi @ThisIsBlecki ,
Thank you for confirming that the logic has been successfully moved to the data warehouse.
Regards,
Harshitha.
User | Count |
---|---|
84 | |
78 | |
70 | |
49 | |
41 |
User | Count |
---|---|
111 | |
56 | |
50 | |
42 | |
40 |