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
jaybears130
Frequent Visitor

Calculated Column Showing Previous Month's Value

I have a table with price indexes for a list of SeriesID's dated for the end of every month.  I want to add a column that will show me the previous month's index for each particular SeriesID in my table.  Can anyone help?

jaybears130_0-1627013692254.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jaybears130 ,

You can create a calculated column as below:

Previous Month's Value = 
VAR _curmonthnum = 'Table'[Month Number]
VAR _curyear = 'Table'[Year]
VAR _year =
    IF ( _curmonthnum = 1, _curyear - 1, _curyear )
VAR _monthnum =
    IF ( _curmonthnum = 1, 12, _curmonthnum - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[seriesID] = EARLIER ( 'Table'[seriesID] )
                && 'Table'[Year] = _year
                && 'Table'[Month Number] = _monthnum
        )
    )

yingyinr_0-1627291235110.png

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @jaybears130 ,

You can create a calculated column as below:

Previous Month's Value = 
VAR _curmonthnum = 'Table'[Month Number]
VAR _curyear = 'Table'[Year]
VAR _year =
    IF ( _curmonthnum = 1, _curyear - 1, _curyear )
VAR _monthnum =
    IF ( _curmonthnum = 1, 12, _curmonthnum - 1 )
RETURN
    CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[seriesID] = EARLIER ( 'Table'[seriesID] )
                && 'Table'[Year] = _year
                && 'Table'[Month Number] = _monthnum
        )
    )

yingyinr_0-1627291235110.png

Best Regards

amitchandak
Super User
Super User

@jaybears130 , I am not seeing index. I am assuming you need value

 

New column

 


Last Month Value =
var _1 = eomonth([Date] ,-1)

var _3 = [SeriesID]
return
sumx(filter(Table, eomonth([Date] ,0) = _1 && [SeriesID] =_3), [Value])

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors