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
kcantor
Community Champion
Community Champion

DAX not returning correct value

I am using a couple of very simple expressions that have worked in the past. My talbe has purchase amounts for our vendors labled as Amount. I have filtered my report to 2015 then created a measure to calculate the previous year purchases and called it Previous Year Purchases.

Previous year Purchases = CALCULATE(SUM('BB$Purch_ Inv_ Line'[Amount]), SAMEPERIODLASTYEAR(DimDate1[DateKey]))

 

I would like to known the year over year growth so my next measure (the first one not working correctly) is subtracting previous year purchases from current year purchases.  The table Name is BB$Purch_Inv_Line. Now normally, I would just use the expression =[Sum of Amount]-[Previous year] but it is not recognizing that name so I tried 'Purch_Inv_Line'[Amount] and of course it said there were to many variables so I went to  = (SUM('BB$Purchase Line'[Amount]))-[Previous year Purchases] Which returns an amount that is not correct. Bellow is a snip of the amounts returned. Can anyone tell me what I have done incorrectly?

This is the expression  : $Variance Current Year = (SUM('BB$Purchase Line'[Amount]))-[Previous year Purchases]

 

The other expression I am not having success with is :

%Variance Current Year = (SUM('BB$Purchase Line'[Amount])-[Previous year Purchases])/[Previous year Purchases]

 

dax.PNG





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

Proud to be a Super User!




3 REPLIES 3
konstantinos
Memorable Member
Memorable Member

Can you share more details like what is the filter context in the table ( nothing, rows with years, products etc). Did you create a measure or a calculated field?

Konstantinos Ioannou

I think there is a bug in that particular data model. I tried to snag some data to carry over and it will not refresh. It says a key does not match a table. I have not received a response from support on this issue. PowerPivot works fine with both the calculation and the data table so i may have to shelve this question for now. As soon as the data becomes accessible I will post some more information.

More context: Rows were week numbers filtered by a manufacturer code. Totals were pulled from a single column in the table and filtered by year. Have the DAX working correctly by using DateAdd - 1 year instead of SamePeriodLastYear.

 





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

Proud to be a Super User!




Greg_Deckler
Community Champion
Community Champion

Can you post a sample of the original data table?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.