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.
Hi everyone,
i have a problem with a dax formula and i hope you can help me.
I want to have a line chart which displays ytd sales for the last 4 years, based on a slicer where i want to select a month up to which the ytd value should be calculated to. Meaning when i select the month 06 for 2021 i want to have in the y axis of the line chart the following values:
for 2021 --> the ytd sales value for 2021 until the month 06
for 2020 -->the ytd sales value for 2020 until the month 06
for 2019 -->the ytd sales value for 2019 until the month 06
for 2018 -->the ytd sales value for 2018 until the month 06
In the x axis i would then drop the year from my calendar do display the evolution of the ytd sales.
Thanks in advance for your help and KR,
Daniel
Solved! Go to Solution.
Hi @trying ,
Is this you want?
If yes, you need create a measure like the following:
Measure =
VAR _ytddate =
FILTER ( ALLSELECTED ( 'Table' ), [Date].[MonthNo] <= MAX ( 'Month'[index] ) )
VAR _ytddate_c =
FILTER (
_ytddate,
[Date] <= MAX ( 'Table'[Date] )
&& [Date].[Year] = MAX ( 'Table'[Date].[Year] )
)
RETURN
IF (
SELECTEDVALUE ( 'Month'[index] ) < MAX ( 'Table'[Date].[MonthNo] ),
BLANK (),
SUMX ( _ytddate_c, [Value] )
)
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @trying ,
Is this you want?
If yes, you need create a measure like the following:
Measure =
VAR _ytddate =
FILTER ( ALLSELECTED ( 'Table' ), [Date].[MonthNo] <= MAX ( 'Month'[index] ) )
VAR _ytddate_c =
FILTER (
_ytddate,
[Date] <= MAX ( 'Table'[Date] )
&& [Date].[Year] = MAX ( 'Table'[Date].[Year] )
)
RETURN
IF (
SELECTEDVALUE ( 'Month'[index] ) < MAX ( 'Table'[Date].[MonthNo] ),
BLANK (),
SUMX ( _ytddate_c, [Value] )
)
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Here is one way to do this:
Data:
Relationship:
Dax:
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
Proud to be a Super User!
Hi,
first off all thanks for the reply and your effort!
Unfortunately this wont solve my issue. I wanted to have one single measure that can do the trick. Is this possible?
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 |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |