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.
Hi,
Could someone please help me on this DAX? I need to calculate YTD/Cumulative total from December to December which means Previous year's Last month (December) to next year's last moth (December). Example Dec'2020 to Dec'2021.
Please find below example in spreadsheet. Please help to calculate YTD/Cumulative amount like below mentioned.
Solved! Go to Solution.
Hi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
YTD and previous December: =
IF (
NOT ISBLANK ( [Amount measure:] ) && HASONEVALUE ( 'Calendar'[Date] ),
CALCULATE ( [Amount measure:], DATESYTD ( 'Calendar'[Date] ) )
+ CALCULATE (
[Amount measure:],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Year]
= MAX ( 'Calendar'[Year] ) - 1
&& 'Calendar'[Month number] = 12
)
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
Hi,
Thank you for your feedback.
The measure has HASONEVALUE(Calendar[Date]) function as a condition. This condition is not to show the total row (when it has more than one date value) in the table visualization.
If you write a measure without HASONEVALUE, it will show as expected.
YTD and previous December: =
IF (
NOT ISBLANK ( [Amount measure:] ),
CALCULATE ( [Amount measure:], DATESYTD ( 'Calendar'[Date] ) )
+ CALCULATE (
[Amount measure:],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Year]
= MAX ( 'Calendar'[Year] ) - 1
&& 'Calendar'[Month number] = 12
)
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
Hi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
YTD and previous December: =
IF (
NOT ISBLANK ( [Amount measure:] ) && HASONEVALUE ( 'Calendar'[Date] ),
CALCULATE ( [Amount measure:], DATESYTD ( 'Calendar'[Date] ) )
+ CALCULATE (
[Amount measure:],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Year]
= MAX ( 'Calendar'[Year] ) - 1
&& 'Calendar'[Month number] = 12
)
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
Hi @Jihwan_Kim
Awesome!! it works pretty well. Thank you so much for your great help.
However, Could you please check this issue? it's working fine when we use Date field, but when we use year and month number /name, then it's showing blank.
Please find below screenshot.
Hi,
Thank you for your feedback.
The measure has HASONEVALUE(Calendar[Date]) function as a condition. This condition is not to show the total row (when it has more than one date value) in the table visualization.
If you write a measure without HASONEVALUE, it will show as expected.
YTD and previous December: =
IF (
NOT ISBLANK ( [Amount measure:] ),
CALCULATE ( [Amount measure:], DATESYTD ( 'Calendar'[Date] ) )
+ CALCULATE (
[Amount measure:],
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Year]
= MAX ( 'Calendar'[Year] ) - 1
&& 'Calendar'[Month number] = 12
)
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
User | Count |
---|---|
81 | |
75 | |
74 | |
42 | |
36 |
User | Count |
---|---|
114 | |
56 | |
51 | |
42 | |
42 |