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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
franpimed
Frequent Visitor

Create new column with the previous period value

Hello,

I'm new in power bi and I'm trying to create a new column that allows me to get the value of the previous month, but I have several columns in the data and I don´t know how to perform the filter. I have tried with previousmonth function, but I do not get the desired value.

 

PREVIOUS VALUE.PNG

 

Power BI File

Thanks for your help.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You can use the following code to generate a new column:

Column = 
VAR __CurrentPeriod = Test[PERIOD D/M/YY]
var __CurrentCountry = Test[COUNTRY]
var __CurrentProduct = Test[PRODUCT]
var __CurrentActivity = Test[ACTIVITY]
RETURN

CALCULATE(
    SUM( Test[CANTIDAD] ),
    FILTER(
        Test,
        Test[COUNTRY] = __CurrentCountry
        && Test[PRODUCT] = __CurrentProduct
        && Test[ACTIVITY] = __CurrentActivity
        && __CurrentPeriod = NEXTMONTH(Test[PERIOD D/M/YY])
    )
)

Prev Month Calc Column.png

View solution in original post

3 REPLIES 3
UK06B1
Helper II
Helper II

Hello I was trying to use the attached thread to solve a similar issue - i cannot get the previous month column to return the previous periods hours (week ending - are weekly periods - link to the week column). see screen shot below which has the formula + the table view. 

 

Therefore for a given employee and a given time stamp and a given week - i would like to return the previous month value so that i can then see on a graph later the difference - or the monthly value - note my data is cumulative data. 

 

The screen shot below shows the current formula i have - 

Any help would be greatly appreciated. 

 

UK06B1_0-1624540298518.png

 

Anonymous
Not applicable

You can use the following code to generate a new column:

Column = 
VAR __CurrentPeriod = Test[PERIOD D/M/YY]
var __CurrentCountry = Test[COUNTRY]
var __CurrentProduct = Test[PRODUCT]
var __CurrentActivity = Test[ACTIVITY]
RETURN

CALCULATE(
    SUM( Test[CANTIDAD] ),
    FILTER(
        Test,
        Test[COUNTRY] = __CurrentCountry
        && Test[PRODUCT] = __CurrentProduct
        && Test[ACTIVITY] = __CurrentActivity
        && __CurrentPeriod = NEXTMONTH(Test[PERIOD D/M/YY])
    )
)

Prev Month Calc Column.png

Amazing. Works perfectly. Thanks for your great solution.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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