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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
gvlado
Advocate II
Advocate II

Running totals backwards

Dear community friends 
I am curious about how to make measure for running totals backwards - from today back into the past.
I have Today inventory, at the end of the day (900),
Also have income end outcome of the inventory for each day (also for this last day - Today)
Question is how to make measure that will calculate inventory for each day backwards !?

gvlado_0-1709041021247.png

 

        
 Inventory at the begining of Today 01.03.2024 was =1000  
        
#DateINOUTIN-OUTInventory  
101.03.2024100200-100900 at the end of the day (Today)
229.02.20241020-10890  
328.02.20243001002001090  
427.02.202420020001090  
526.02.202410050501140  
625.02.202410200-190950  
724.02.20245060-10940  
923.02.20241005050990  
1022.02.202410040601050  
1121.02.2024300301080  
1220.02.2024050-501030  
1319.02.20242010101040  
..................  

Ice cream is free by me. 
Thanks a lot for your effort.

2 ACCEPTED SOLUTIONS
v-yilong-msft
Community Support
Community Support

Hi @gvlado ,

As Nithinr said, it is possible to do what you need to do based on this DAX code, here are my thoughts and additions.

First create a table.

vyilongmsft_0-1709175010799.png

A slight change to Nithinr's DAX code will give you the results you need.

MEASURE =
VAR _A =
    CALCULATE (
        SUM ( 'Table'[IN-OUT] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] >= MIN ( 'Table'[Date] ) )
    )
VAR _AA = _A + 900
RETURN
    _AA

vyilongmsft_1-1709175104722.png

 

 

 

Best Regards

Yilong Zhou

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

Small correction 900 -> 1000
And types of columns must be defined
---- BOMeasure----------
Measure
=
VAR _A = CALCULATE(
    SUM('Table'[IN-OUT]),
    FILTER(
        ALL('Table'),
        'Table'[Date] >= MIN('Table'[Date])
    )
)
VAR _AA = _A + 1000
RETURN
_AA
--- EOMEasure---

View solution in original post

8 REPLIES 8
gvlado
Advocate II
Advocate II

It should go like ilustration on the excell
Starting inventory for beginning of the day is separated table. IN-OUT is change for each day (it is 2nd table)
After loading both table I have Inventory and Change of inventory by day backwards (1000 - 100=900, then 900 - 10=890,  then 890+200=1090, ....etc). The question is how measure for Inventory at the end of the day should look like.

gvlado_2-1709197093815.png

 

Ashish_Mathur
Super User
Super User

Hi,

For closing inventory on 1/3/2024 to be 900, the closing inventory on 29/2/2024 should be 1000.  Why is it 890?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

It is because receiving (IN=10) and deliveiring (OUT=20) -> means that this day was inventory smaller for 10 (-10). So, I have in and out for every day. Only for last day (1/3/2024) there is data fon inventory at the end of the day. It means calculation of inventory starts from 1000.

Hi,

I have solved a similar problem in the attached PBI files.  Please review them and adapt them to your setup.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yilong-msft
Community Support
Community Support

Hi @gvlado ,

As Nithinr said, it is possible to do what you need to do based on this DAX code, here are my thoughts and additions.

First create a table.

vyilongmsft_0-1709175010799.png

A slight change to Nithinr's DAX code will give you the results you need.

MEASURE =
VAR _A =
    CALCULATE (
        SUM ( 'Table'[IN-OUT] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Date] >= MIN ( 'Table'[Date] ) )
    )
VAR _AA = _A + 900
RETURN
    _AA

vyilongmsft_1-1709175104722.png

 

 

 

Best Regards

Yilong Zhou

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

Small correction 900 -> 1000
And types of columns must be defined
---- BOMeasure----------
Measure
=
VAR _A = CALCULATE(
    SUM('Table'[IN-OUT]),
    FILTER(
        ALL('Table'),
        'Table'[Date] >= MIN('Table'[Date])
    )
)
VAR _AA = _A + 1000
RETURN
_AA
--- EOMEasure---

how did you get 940?
Should go like it is on ilustration

gvlado_0-1709196895700.png

 

Nithinr
Resolver III
Resolver III

Is this the one you are looking for

Reverse Cumulative Total = 
CALCULATE(
    SUM('Table'[Inventory]),
    FILTER(
        ALL('Table'),
        'Table'[Date] >= MIN('Table'[Date])
    )
)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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