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.
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:
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |