Forum Discussion
DateAdd function in column not working
- 8 years ago
Hi anandav,
This is a question of context, if you remove the previous month from your table view it will give you the calculation you need.
Be aware that the measure are very sensitive in terms of context and if you don't place a certain column in your measure, when you add that measure with that column the value will be off.
Regards,
MFelix
Hi MFelix,
I have uploaded the pbix file here.
I am not using Date table and still it does not work. Could you please check the file to see what I am doing wrong?
Thank you for your patience regarding this problem.
Hi anandav,
This is a question of context, if you remove the previous month from your table view it will give you the calculation you need.
Be aware that the measure are very sensitive in terms of context and if you don't place a certain column in your measure, when you add that measure with that column the value will be off.
Regards,
MFelix
- anandav8 years agoSkilled Sharer
Hi MFelix,
Thanks a lot for the help. Yes, that works in the measure.
I've been strugking with this for 2 days now. :smileyhappy:
But the same formula does not work in a column. How do I use DateAdd in a column to get previous month sales?
- MFelix8 years agoSuper User
Hi anandav,
I don't understand why you want to create a column previou month value, this is the type of information you should use as measure.
As a DAX best practice if you can calculate a value as measure don't create a calculated column.
The use of the DAX formulas is not the same in a calculated measured or in a column, this as to do with context. So you must be carefull in the way you make the use of the formulas.
Looking at the calculations you are using on the column the formula you use with the earlier works correctly since the column uses the line context so it looks at a single line and get the earlier value (previous line), when you use the DATEADD the context is different and you are trying to find in all your table what is the previous month lines and then return their value. Chekc also the DATEADD formula documentation because it also show some limitations like the fact that the result table includes only dates that exist in the dates column.
Can you please explain why do you want to use a column instead of a measure?
Regards,
MFelix