Forum Discussion

CGarciaV's avatar
CGarciaV
New Member
3 years ago

Calculate inventory per month

Hello, I want to calculate the inventory per month.

I have 3 tables: 

1)Warehouses master data (ID /State /City)

 

WarehouseIDSTATECITY
CHIST000030CHIHUAHUACHIHUAHUA
BCIST000011BAJA CALIFORNIA NORTEENSENADA
ASIST000016AGUASCALIENTESAGUASCALIENTES

 

2)Warehouse with Qty per material purchases (IN) and consumption (OUT)

 

WarehouseIDDateItemIDPURCHASECONSUMPTION
CHIST00003005-ene-23ABC1                    10                      1
CHIST00003031-ene-23ABC2                    15                      3
CHIST00003031-ene-23ABC1                    20                      3
CHIST00003001-feb-23ABC2                    30                      3
BCIST00001101-feb-23ABC1                    15                      4
BCIST00001101-feb-23ABC2                    -                        3
BCIST00001101-feb-23ABC1                    10                      3
CHIST00003001-feb-23ABC2                    -                        3
ASIST00001628-feb-23ABC1                      9                      3
ASIST00001628-feb-23ABC2                    28                      5
BCIST00001101-mar-23ABC1                    -                        2
CHIST00003006-mar-23ABC2                      5                      3
ASIST00001606-mar-23ABC1                    12                    -  
ASIST00001606-mar-23ABC2                    12                    15
CHIST00003006-mar-23ABC1                    32                    -  
CHIST00003006-mar-23ABC2                    90                    -  
CHIST00003006-mar-23ABC1                    -                        3
CHIST00003006-mar-23ABC2                      3                    -  
CHIST00003006-mar-23ABC1                    -                        3
CHIST00003006-mar-23ABC2                    20                      3
CHIST00003030-mar-23ABC1                    -                      15
CHIST00003030-mar-23ABC2                    -                        3

 

3)Dates.

 

Date
01-ene-23
02-ene-23
03-ene-23
04-ene-23
05-ene-23
06-ene-23
07-ene-23
08-ene-23
09-ene-23
10-ene-23
11-ene-23
31-dic-23

 

Here's the desired result:

 

Thank You!!

1 Reply

  • CGarciaV , You need to use running total with help from date table joined to date of your table

     

     CALCULATE(SUM(Table[PURCHASE]),filter(date,date[date] <=maxx(date,date[date]))) - CALCULATE(SUM(Table[CONSUMPTION]),filter(date,date[date] <=maxx(date,date[date])))

     

    Power BI Inventory On Hand: https://youtu.be/nKbJ9Cpb-Aw