Forum Discussion
Using variable to calculate data of previous date & current date
- Anonymous4 years ago
My bad...mistakenly clicked the button to accept the solution...
I modified the one from Anonymous a little bit
Previous WIP1 = CALCULATE(SUM([Today WIP]),FILTER('Data', 'Data'[Description]=EARLIER('Data'[Description]) &&'Data'[Date]<EARLIER('Data'[Date]) &&'Data'[Line]=EARLIER('Data'[Line]) &&'Data'[File No]=EARLIER('Data'[File No]) &&[Op. No]=EARLIER('Data'[Op. No])))Anonymous how can I undo Accept the solution?
Hi
Can you please kindly advise if there is something wrong with the Variable calculation for Previuos date?
My bad...mistakenly clicked the button to accept the solution...
I modified the one from Anonymous a little bit
Previous WIP1 =
CALCULATE(SUM([Today WIP]),FILTER('Data',
'Data'[Description]=EARLIER('Data'[Description])
&&'Data'[Date]<EARLIER('Data'[Date])
&&'Data'[Line]=EARLIER('Data'[Line])
&&'Data'[File No]=EARLIER('Data'[File No])
&&[Op. No]=EARLIER('Data'[Op. No])))
Anonymous how can I undo Accept the solution?
- thongnguyen24144 years agoFrequent Visitor
Hi Anonymous
1. I am always appreciated for your kindly help. 😍
2. Actually, I shorted my data by operation to get it shorter because the original one is too long as 1 operation has many people working for. I am sorry about not showing enough data.
3. Because of my mistake, when running fomular, it counted x2, x3, x4 ...
Therefore, I edited the fomular by deviding to countax for removing duplicates value.
The fomular seems to be loong, doesn't it ? 😊
Is there another way to make it shorter?
- Anonymous4 years agoNot applicable
It does not matter whether the code is long or not, but it does matter whether it has side effect...I am not a fan of EARLIER, so always use Variable...you can go to DAX Formatter to format your DAX code, practising with different formulas and you will find a better way