Forum Discussion

thongnguyen2414's avatar
thongnguyen2414
Frequent Visitor
4 years ago
Solved

Variable for Repeatable calculation

Hello

 

- I really need your advices about the variable for something like Repeatable calculation ( I have no idea if I can call it like this ^^ )

- I am in trouble to calculate column/data for the 'Previous Date. Operation WIP' because :

1. The 'Previous Date.Operation WIP' for today = Today Operation WIP (yesterday) + Previous Date. Operation WIP (yesterday)

2. For the 'Today Operation WIP' (yesterday, we can calculate. However; I have no idea how to calculate the 'Previous Date. Operation WIP' (yesterday) because it also is depended on the data of the day before yesterday (with the same logic)

 

For example:

Please kindly help to look at the attached photo which I have explained. Thank you.

Here is my data

 

DateLineFile NoDescriptionOp. NoQ'ty
6/1/2021 0:00LINE 5VSCG213604941760
6/1/2021 0:00LINE 5VSCG2136049421398
6/1/2021 0:00LINE 5VSCG2136049431664
6/1/2021 0:00LINE 5VSCG2136049441715
6/1/2021 0:00LINE 5VSCG2136049451783
6/1/2021 0:00LINE 5VSCG2136049461758
6/1/2021 0:00LINE 5VSCG2136049471508
6/1/2021 0:00LINE 5VSCG2136049481434
6/1/2021 0:00LINE 5VSCG2136049491444
6/2/2021 0:00LINE 5VSCG2136049412155
6/2/2021 0:00LINE 5VSCG2136049422304
6/2/2021 0:00LINE 5VSCG2136049431811
6/2/2021 0:00LINE 5VSCG2136049441773
6/2/2021 0:00LINE 5VSCG2136049451950
6/2/2021 0:00LINE 5VSCG2136049461867
6/2/2021 0:00LINE 5VSCG2136049471961
6/2/2021 0:00LINE 5VSCG2136049481737
6/2/2021 0:00LINE 5VSCG2136049492070
6/3/2021 0:00LINE 5VSCG2136049412279
6/3/2021 0:00LINE 5VSCG2136049422131
6/3/2021 0:00LINE 5VSCG2136049431926
6/3/2021 0:00LINE 5VSCG2136049441891
6/3/2021 0:00LINE 5VSCG2136049452052
6/3/2021 0:00LINE 5VSCG2136049462112
6/3/2021 0:00LINE 5VSCG2136049472046
6/3/2021 0:00LINE 5VSCG2136049482097
6/3/2021 0:00LINE 5VSCG2136049492026
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi thongnguyen2414 ,

     

    I'd suggest you create measures instead:

    _1 = 
    var _pre= CALCULATE(SUM('Table'[Q'ty]),FILTER(ALLSELECTED('Table'),[Date]=MAX('Table'[Date])&&  [Op. No]=MAX('Table'[Op. No])-1))
    return IF(_pre=BLANK(),BLANK(),  SUM('Table'[Q'ty]) -_pre)
    _2 = CALCULATE([_1],PREVIOUSDAY('Table'[Date]))
    _3 = [_1]+[_2] 
    _5 = CALCULATE([_3],PREVIOUSDAY('Table'[Date]))
    _6 = [_1]+[_5]

    The final output is shown below:

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Ehren's avatar
    Ehren
    Microsoft Employee

    Are you trying to do this in Power Query/M or in DAX? (This is the area of the forum for PQ questions.)

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    is it the logic? 

    1, Column 6 always equal the total amount until today

    2, Column 5 is the total amount until yesterday

    3, Column 4 is Column6 - Column5

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi thongnguyen2414 ,

     

    I'd suggest you create measures instead:

    _1 = 
    var _pre= CALCULATE(SUM('Table'[Q'ty]),FILTER(ALLSELECTED('Table'),[Date]=MAX('Table'[Date])&&  [Op. No]=MAX('Table'[Op. No])-1))
    return IF(_pre=BLANK(),BLANK(),  SUM('Table'[Q'ty]) -_pre)
    _2 = CALCULATE([_1],PREVIOUSDAY('Table'[Date]))
    _3 = [_1]+[_2] 
    _5 = CALCULATE([_3],PREVIOUSDAY('Table'[Date]))
    _6 = [_1]+[_5]

    The final output is shown below:

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.