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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jsteffe
Helper III
Helper III

Difference between measure and calculated column

Hello,

If I write this formula in a measure, I get the good result as it calculates the amount of sales for the next year.

CALCULATE(SUM(Sales[amount]);NEXTYEAR('Calendar'[Date]))
 
But if I put the same formula into a calculated column of table Sales, I get only blank values.
 
Can someone explain me why ?
 
Thanks for your help.
1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @jsteffe ,

 

It is because of the row context,you need to correct your expression as below:

 

CALCULATE(SUM(Sales[amount]),'Sales',NEXTYEAR('Calendar'[Date]))

 

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

5 REPLIES 5
v-kelly-msft
Community Support
Community Support

Hi @jsteffe ,

 

It is because of the row context,you need to correct your expression as below:

 

CALCULATE(SUM(Sales[amount]),'Sales',NEXTYEAR('Calendar'[Date]))

 

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Greg_Deckler
Super User
Super User

Because you are in Row context, you likely need to break out of row context using ALL.

 

CALCULATE(SUM(ALL(Sales[amount]));NEXTYEAR('Calendar'[Date]))


@ 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...

Hi Greg,

Your proposal :

CALCULATE(SUM(ALL(Sales[amount]));NEXTYEAR('Calendar'[Date]))

doesn't work because the first parameter of SUM function requires the name of a column.

 

I created a table Calendar and a relationship between this table and my table Sales. That's why in the row context I thought that this formula will calculate for each row the total amount of sales for the next year (of my actual row)

CALCULATE(SUM(Sales[amount]);NEXTYEAR('Calendar'[Date]))
This one doesn't work too :
CALCULATE(SUM(Sales[amount]);NEXTYEAR(Sales[SaleDate]))
 
 
 

Hi @jsteffe ,

 

Have you tried my measure?I have tested here and it works.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Sorry I did'nt see your reply.

It perfectly works. Thanks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.