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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Sameperiodlastyear ()

Hello,

 

I want to add a column to calculate inventory value of end of last year. Please advise how to write the Measure. Thank you

Capture.PNG

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous ,

new column last year same value =

var _date = eomonth([date],-12)

var _company = [company]

return


sumx(filter(Table, [Company] = _company && eomonth([date],0) = _date ) , [Inventory])

 

 

YTD a new column =
sumx( filter(Table,[Company] = _company && [Date] <= earlier([Date]) && year([Date]) = year(earlier([Date]) )), [Inventory])

 

 

For measure

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @Anonymous 

 

Create a column like below:-

Column =
VAR prev =
    YEAR ( [date] ) - 1
RETURN
    CALCULATE (
        SUM ( 'Table (3)'[inv] ),
        FILTER (
            'Table (3)',
            [date] = DATE ( prev, 12, 31 )
                && 'Table (3)'[company] = EARLIER ( 'Table (3)'[company] )
        )
    )

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

amitchandak
Super User
Super User

@Anonymous ,

new column last year same value =

var _date = eomonth([date],-12)

var _company = [company]

return


sumx(filter(Table, [Company] = _company && eomonth([date],0) = _date ) , [Inventory])

 

 

YTD a new column =
sumx( filter(Table,[Company] = _company && [Date] <= earlier([Date]) && year([Date]) = year(earlier([Date]) )), [Inventory])

 

 

For measure

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.