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! Learn more

Reply
Chandrash12
Frequent Visitor

Calculate variance based on previous month value

Hello All,

 

New to Power BI and looking forward for some guidance.

 

I have 7 columns and i need to calculate variance at aggreaget level of Code and Account compared to previous month based on amt.

 

 

Chandrash12_1-1661770895330.png

Period is month and Year = year.

 

I need to get the variance 0.054 for this sample set. 

 

Chandrash12_2-1661771053058.png

 

Regards,

Chandrakanth.K

 

6 REPLIES 6
Chandrash12
Frequent Visitor

Need help

Anonymous
Not applicable

HI @Chandrash12,

That is a calculated table expression, you can't use it in other types of calculated fields. Please create a new calculated table to use these formulas.

Regards,

Xiaoxin Sheng

Hello Xiaoxin Sheng,

 

Thank you for your response. I understood and create table first and tried to use this DAX in add custom column but i get two error

1.

Chandrash12_0-1662383296345.png

and 2

Chandrash12_1-1662383335062.png

 

 

Anonymous
Not applicable

Hi @Chandrash12,

They are DAX formulas, you need to use them on the data model side instead of the power query.

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@Chandrash12 , Create a date using year and month and then join it with a date table having year and month

 

Date = Date([year],[month],1)

 

Calendar = Addcolumns(calendar(date(2020,01,01), date(2021,12,31) ), "Month no" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Qtr Year", format([date],"yyyy-\QQ")
, "Qtr", quarter([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])
, "Is Today" ,if([Date]=TODAY(),"Today",[Date]&"")
, "Month Type", Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY") )
,"Year Type" , Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)
)

 

 

Then create measures like these and take diff for variance.

 

Use table from date table in visual slicer

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

 

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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

Thank you Amit for your response. I tried and i am getting this below errors when i tried to create new column/measure.

 

Chandrash12_0-1661777135568.png

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.