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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Nsimpson
Frequent Visitor

How to create measures for the previous month and same month last year?

When I try to create the below measure I get the following error.

 

TEST Prev Month = CALCULATE(SUM('tbl6PakData_Archive'[Inv6Pak]),DATEADD('tbl6PakData_Archive'[Month],-1,MONTH))

 

 

Nsimpson_2-1649266809323.png

I would also like to show values for the same month 12 months in the past using a simliar measure.  

 

Here is what my month column looks like. The data type is Date.

Nsimpson_3-1649266947446.png

 

Vendor Name	Last Month	Same Month LY
Test Vendor	$45,000 	$30,000 

 

Any suggestions?

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Nsimpson ,

Please adjust your measure according to the following template:

premonth = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),DATEADD('Table'[date],1,MONTH)=  MAX('Table'[date])))
preYEAR = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),DATEADD('Table'[date],1,YEAR)=  MAX('Table'[date])))

vluwangmsft_0-1649917378146.png

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

View solution in original post

3 REPLIES 3
v-luwang-msft
Community Support
Community Support

Hi @Nsimpson ,

Please adjust your measure according to the following template:

premonth = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),DATEADD('Table'[date],1,MONTH)=  MAX('Table'[date])))
preYEAR = CALCULATE(MAX('Table'[value]),FILTER(ALL('Table'),DATEADD('Table'[date],1,YEAR)=  MAX('Table'[date])))

vluwangmsft_0-1649917378146.png

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

YukiK
Impactful Individual
Impactful Individual

DATEADD() uses a date table containing dates.

Do you have some other column like "relative month value" with values of 0,-1,-2, etc? If so, then you can do something like this:

TEST Prev Month = CALCULATE(SUM('tbl6PakData_Archive'[Inv6Pak]), "your table"[relative month value] = -1  )

 

I added relative month to my date table but and updated the measure to the below and all the values were blank.  Any other suggestions?

 

Nsimpson_0-1649270057716.png

TEST Prev Month = CALCULATE(SUM('tbl6PakData_Archive'[Inv6Pak]), 'M1VAULT_STG DATE_DIM'[Relative_Month] = -1)

Nsimpson_1-1649270235861.png

Nsimpson_3-1649270280857.png

 

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