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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
anjanikumar
Helper III
Helper III

Comparing this year and last year and need subtraction as well.

YoY =
Var visitp = CALCULATE(SUM('ga_goal_aggr_vw_1'[visits_count]),SAMEPERIODLASTYEAR('dm_behaviour_web_cal_source'[date]))
return
IFERROR((Divide((SUM('ga_goal_aggr_vw_1'[visits_count])-visitp),visitp)),0)

 

this measure i am writing for comparing this year and last year sales and need to subtraction of that, but above measure is working for only 2 days not more then that. please help me asap.

 

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @anjanikumar 

The solution is usually to create two variables that capture last year's and current year's sales, and then subtract them.

we need information below to work on it further, could you provide it?

 (1) a sample file, you can replace raw data with bogus data to protect your privacy.

     or provide some sample data that fully covers your issue/question.

(2) give your expected result based on the sample you provide.

Kindly note: Please ensure the data in sample is concise and representative.

Thanks.

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@anjanikumar , You need use date table to make sure time intelligence works

 

example

 

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

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

 

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.