Forum Discussion
Unable create measure for rolling PROFIT
Hi All
I have create a measure below work fine :-
When i try to create a rolling profit i get error :-
It cannot detect SALES[PROFIT]
May i know why ?
Paul
Anonymous
Try to delete SUM('Sales' from before profit. Profit is a measure so you don't need to sum it again.
Rolling 12 Month = CALCULATE([Profit], DATESINPERIOD( ...
continue the rest of your measure as is.
DAX best practice naming convention says:
1) When referring to COLUMN - put table name in front: Table[Column]
2) When referring to MEASURE - do NOT put table name in front: [Measure]
This is good practice to follow, as measures do not belong to a table. They must be unique across the entire data model. It is also possible to change the 'home table' of a measure. Finally, DAX gurus expect this naming convention, so it's easier for us to read your code if you follow it.
4 Replies
- AllisonKennedyCommunity Champion
Anonymous
Try to delete SUM('Sales' from before profit. Profit is a measure so you don't need to sum it again.
Rolling 12 Month = CALCULATE([Profit], DATESINPERIOD( ...
continue the rest of your measure as is.
DAX best practice naming convention says:
1) When referring to COLUMN - put table name in front: Table[Column]
2) When referring to MEASURE - do NOT put table name in front: [Measure]
This is good practice to follow, as measures do not belong to a table. They must be unique across the entire data model. It is also possible to change the 'home table' of a measure. Finally, DAX gurus expect this naming convention, so it's easier for us to read your code if you follow it.
- parry2kSuper User
Anonymous AllisonKennedy provided the correct solution. Also when you are referring to Measures in your calculations, don't use a Table name with the measure. Measures are global to your model and as a best practice, don't use table names when using measures in another measure.
- amitchandakSuper User
Anonymous , to me profit seem like a measure. If it is a measure sum will not work. Sumx Can
calculate(Sumx(Table, [Profit]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))
Or simply measure
calculate( [Profit],DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))
- v-jingzhangCommunity Support
Hi Anonymous , has this problem been solved? If so, kindly accept the proper reply as the solution. More people will benefit from it. Otherwise if you are still confused about it, please provide more details about your problem. Thanks a lot.
Best Regards,
Community Support Team _ Jing Zhang