Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I'd like to be able to use a variable in for the requirement in this formula,
TOTALYTD( [Expenses], Calendar[Date], ALL('Calendar'), "9/30")
I want to be able to use a variable to replace the "9/30" so I can easily change this in multiple calculations. When I do input a variable there, even when I try making the variable exactly the same as what's there now, the formula breaks.
Has anyone experienced this?
Hi @Anonymous
I can't find a way to make totalytd accept the end-of-year string as anyting other than a string.
The workaround would be to create a measure for ytd yourself:
Measure =
VAR _currentDate =
CALCULATE ( MAX ( Dates[Date] ) )
VAR _eoyMonth =
MONTH ( [endOfYear] )
VAR _eoyDay =
DAY ( [endOfYear] )
VAR _min =
IF (
MONTH ( _currentDate ) > _eoyMonth;
DATE ( YEAR ( _currentDate ); _eoyMonth; _eoyDay );
DATE ( YEAR ( _currentDate ) - 1; _eoyMonth; _eoyDay )
)
VAR _max =
IF (
MONTH ( _currentDate ) > _eoyMonth;
DATE ( YEAR ( _currentDate ) + 1; _eoyMonth; _eoyDay );
DATE ( YEAR ( _currentDate ); _eoyMonth; _eoyDay )
)
RETURN
CALCULATE (
SUM ( 'Table'[sales] );
FILTER (
ALL ( Dates );
Dates[Date] <= MAX ( Dates[Date] )
&& Dates[Date] > _min
&& Dates[Date] <= _max
)
)
where
endOfYear = date(2019;6;30)
Cheers,
Sturla
If this post helps, then please consider Accepting it as the solution. Kudos are nice too.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
21 | |
16 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
19 | |
18 |