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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
thongnguyen2414
Frequent Visitor

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.

thongnguyen2414_0-1634047001343.png

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
1 ACCEPTED SOLUTION
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:

Eyelyn9_0-1635326490418.png

 

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.

View solution in original post

3 REPLIES 3
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:

Eyelyn9_0-1635326490418.png

 

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.

wdx223_Daniel
Super User
Super User

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

Ehren
Microsoft Employee
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.)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors