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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Super User
Super User

Can you post a sample of the original data table?


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors