Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
hmed435
Frequent Visitor

Include Previous Year last day amount to current YTD amount

Hi All,

 

I have to ask for a measure to include 12/31 days amount added into current year YTD amount. 

 

Date                  Amount   YTD Amount   CAL YTD Amount

12/31/2021        2              2                      2 + (Amount from 12/31/2020)

 

12/1/2022          1              1                      3  

12/2/2022                          1                      3

12/3/2022          2              3                      5

.

.

.

12/29/2022                        3                      5

12/30/2022        2              5                      7

12/31/2022        2              7                      9

 

1/1/2023            2              2                      4

 

If you see 1/1/2023 CAL YTD amount it is adding 12/31/2022 Amount of 2 and then 1/1/2023 amount of 2. 

 

YTD Amount: CALCULATE(SUM(Amount), DATESYTD(Date))  

 

I tried below Dax exp for CAL YTD Amount but not calculating correctly. 

CAL YTD Amount: CALCULATE(SUM(Amount), DATESYTD(IF(MONTH(Date) = 12 && DAY(Date) = 31, Date + 1, Date)))

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but if you have a Date table (Dimension table) and a Sales table (Fact table), try something like below. It is for creating a measure.

 

Expected result measure: =
CALCULATE ( SUM ( Sales[Amount] ), DATESYTD ( Date[Date] ) )
    + CALCULATE (
        SUM ( Sales[Amount] ),
        Date[Date]
            = DATE ( MAX ( Date[Year] ) - 1, 12, 31 )
    )

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but if you have a Date table (Dimension table) and a Sales table (Fact table), try something like below. It is for creating a measure.

 

Expected result measure: =
CALCULATE ( SUM ( Sales[Amount] ), DATESYTD ( Date[Date] ) )
    + CALCULATE (
        SUM ( Sales[Amount] ),
        Date[Date]
            = DATE ( MAX ( Date[Year] ) - 1, 12, 31 )
    )

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you for your reply. I had to tweak a little to get that expression work see below which i used in my DAX query. It was giving me below error if i am not using filter as below. 

 

Error Without Filter Funtion: a function max has been used in a true/false expression that is used as a table filter expression

 

CALCULATE ( SUM ( Sales[Amount] ), DATESYTD ( Date[Date] ) )
    + CALCULATE (
        SUM ( Sales[Amount] ),
        FILTER( ALL ( Date[Date] ), Date[Date]
                                  = DATE ( MAX ( Date[Year] ) - 1, 12, 31 )
               )
    )

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.