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
Here is the Table named test:
Here is the table 2 which contains Dates, which is used as Slicer:
Dates = CALENDAR(date(2022,1,1),TODAY())
Link between Dates and test dataset:
Question: Create a Measure that shows the YTD Total amount for the current year, even if the date slicer starts from the previous year:
Here is my code:
YTD =
VAR minim = CALCULATE( MIN( Dates[Date]), ALLSELECTED(Dates[Date]))
var startyear = DATE(YEAR(TODAY()),1,1)
return if( minim >= startyear ,
calculate(sum(test[Totals] ), FILTER(Dates, Dates[Date] >= startyear)) ,
calculate(sum(test[Totals] ), FILTER(Dates, Dates[Date] >= startyear)) )
Test Scenario 1 Works fine: Shows correct info, the date slicer starts at 2022, and the measure shows the YTD result of current year
Test Scenario 2: Does Not Work, Shows 40 instead of 130 (Expected output 130)
Test Scenario 3: Does not work, Even when the year is the current year, (Expected output 130)
Solved! Go to Solution.
Hi @bipowerbix
I got the desired result, please try the below measure.
-------------------------------------------------------
-------------------------------------------------
--------------------------------------------------------------------------
Regards,
Novil
If I answer your question, please mark my post as a solution.
Nice man, I will use this in future cases
Hi @bipowerbix
I got the desired result, please try the below measure.
-------------------------------------------------------
-------------------------------------------------
--------------------------------------------------------------------------
Regards,
Novil
If I answer your question, please mark my post as a solution.
Hi FreemanZ,
The expected output for all test scenarios should be 130, that is the YTD total for the current year.
hi @
why YTD in scenario 2 and 3 are 130?
That's what we want to achieve, For 2023, We have 3 records, 40,80, and 10, which adds up to 130. Need to show 130 in card visual using DAX measure,
try like:
Measure =
SUMX(
FILTER(
ALL(test),
test[date]=YEAR(MAX(dates[date]))
&& test[date]<=TODAY()
)
test[Totals]
)
Doesn't Work, Gives output as blank. (Image below of Visual titled Measure)
hi @bipowerbix
there is a typo, try like:
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 21 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 35 | |
| 31 | |
| 20 | |
| 13 | |
| 10 |