Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All
I'm messing around with calculation groups and found something weird happening when I filter my dimension.
So I have calculation that do YTD, MTD, WTD etc and they all work fine. See below, I've changed my measure to return 1 if its not blank and 0 if it is for obvious reasons
Unfiltered
You can see some codes have a 1 others a 0 and the total is 1 (with real numbers this is accurate)
If I remove any code (blank in this case) everything is 0 except for the total
Filtered
MTD and the other do not have this problem. DAX below
YTD - (Not working)
VAR Year = CALCULATE( SELECTEDVALUE( Dates[Year] ), Dates[IsTodayFlag] = TRUE() )
VAR ReturnValue = CALCULATE( SELECTEDMEASURE(), Dates[Year] = Year, Dates[Is Part Of Current Year?] = TRUE() )
RETURN
IF( ReturnValue = BLANK(), 0, 1 )
MTD - (Working)
VAR Year = CALCULATE( SELECTEDVALUE( Dates[Year] ), Dates[IsTodayFlag] = TRUE() )
VAR CDate = CALCULATE( SELECTEDVALUE( Dates[Date]) , Dates[IsTodayFlag] = TRUE() )
VAR CMonth = CALCULATE( SELECTEDVALUE( Dates[Month] ), Dates[Date] = CDate )
VAR ReturnValue = CALCULATE( SELECTEDMEASURE(), Dates[Year] = Year, Dates[Month] = CMonth, Dates[Is Part Of Current Year?] = TRUE() )
RETURN
IF( ReturnValue = BLANK(), 0, 1 )
I know the measures can be written better, i.e. using DATESYTD etc, but like I said, im just playing at the moment
Hi @MCornish ,
I don't reproduct your problem, could you please share your PBIX file that doesn't contain sensitive data?
Best Regards,
Winniz
@MCornish , these are various version without TI
This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
diff % = divide([This Year]-[Last Year ],[Last Year ])
Year Rank = RANKX(all('Date'),'Date'[Year Start date],,ASC,Dense)
This Year = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])))
Last Year = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1))
Day of Year =datediff([Year Start date] , [Date],Day) +1
YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank]) && 'Date'[Day of Year] <= Max('Date'[Day of Year]) ))
LYTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year Rank]=max('Date'[Year Rank])-1 && 'Date'[Day of Year] <= Max('Date'[Day of Year])))
YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Month] <= Max('Date'[Month]) ))
LYTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Month] <= Max('Date'[Month])))
YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Qtr] <= Max('Date'[Qtr]) ))
LYTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Qtr] <= Max('Date'[Qtr])))
Year Week = [Year]*100 +[Week]
YTD= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] <= Max('Date'[Week]) ))
LYTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] <= Max('Date'[Week])))
You can check , if these can help
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
https://www.youtube.com/watch?v=8-TlVx7P0A0
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
https://www.youtube.com/watch?v=pnAesWxYgJ8
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 36 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |