Forum Discussion
How to exclude / filter last month YTD-calculation
- 6 years ago
Hi there,
No, this does not meet the requirements if you roll it up to year.
Anyhow, this is how fixed the issue myself:
# Quantity Prep =var quantity =CALCULATE ( [# Quantity YTD] - [# Quantity YTD PM] , DIM_Calendar[Monthnumber] <> 1 )var selected_month = SELECTEDVALUE ( DIM_Calendar[Monthnumber])returnSWITCH ( true,selected_month = 1 , [# Quantity YTD] ,ISBLANK([# Quantity YTD]) , BLANK() ,quantity)# Quantity =sumx ( VALUES ( DIM_Calendar[Year/Month] ) , [# Quantity Prep])
The Quantity YTD PM shows the 300 in 2019-01, is it the value in 2018-12? --> Yes, it's the value of the previous month.
You Quantity logic is Quantity = [Quantity YTD] - [Quantity YTD PM], what is the 0 logic in 2019-01? Do you want to show the blank in Quantity YTD PM, then the Quantity is 0? --> it should be 0 because the year starts here.
Thanks for asking the right questions and helping me out.
Hi there,
Your solution: https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Revenue-Reverse-YTD/m-p/373185#M111
does not work if you plot your solution in a matrix-table.
- v-zhenbw-msft6 years ago
Community Support
Hi JohanData ,
Please allow us to confirm once again whether our understanding is correct.
When we select the 2019, in 2019-01, the Quantity YTD will show 30, Quantity YTD Previous Month will show 300, and the Quantity will show 0.
If it is your requirement, we can add an IF function in your Quantity measure.
Quantity = IF( MAX(DIM_Calender[Monthnumber])=1,0, [Quantity YTD] - [Quantity YTD PM])If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
- JohanData6 years ago
Resolver I
Hi there,
No, this does not meet the requirements if you roll it up to year.
Anyhow, this is how fixed the issue myself:
# Quantity Prep =var quantity =CALCULATE ( [# Quantity YTD] - [# Quantity YTD PM] , DIM_Calendar[Monthnumber] <> 1 )var selected_month = SELECTEDVALUE ( DIM_Calendar[Monthnumber])returnSWITCH ( true,selected_month = 1 , [# Quantity YTD] ,ISBLANK([# Quantity YTD]) , BLANK() ,quantity)# Quantity =sumx ( VALUES ( DIM_Calendar[Year/Month] ) , [# Quantity Prep])