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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Measure using current inventory measure

Hi, I'm currently working on an inventory report, so I have a main table with inventory movement posting and also a date table. There are various attributes for each entry, such as location (plant), material, storage type (jumbo/pallet), etc. I need a measure that will calculate the monthly % average of inventory stored in jumbo vs pallet. I also have slicers from the main table in the report, so the measure should work with it. 

 

For each month, the calculation would be as follows for % pallet: (sum of daily inventory levels stored on pallets)/(sum of total daily inventory stored on pallets and jumbo). The same for % jumbo.

I cannot store daily inventory levels in a dax table because the current posting table encompases two years worth of information (~a million rows) with many materials, locations, etc.

 

This is my current measure for inventory on hand:

 

Inventory on hand = 
var _currdate=MAX('Date Table'[Date])
return

CALCULATE(
    SUM('Table'[Quantity]),
    FILTER(
        ALLSELECTED('Date Table'[Date]),
        ISONORAFTER('Date Table'[Date], _currdate, DESC)
    )
)

 

When plotted against the date field, I can get daily inventory levels.

 

Here's some sample data for posting table:

QuantityMaterial CodePosting dateStorage TypePlant Code
136.85M1055618-Oct-20Jumbo5320
6634690D00AO25-Oct-20Pallet5320
-60M21109B25-Nov-20Jumbo5320
6634690D00AO25-Nov-20Jumbo5320
-20M2611816-Dec-20Jumbo5320
-50.834690D01AO18-Dec-20Pallet5320
0.634690D00AO26-Dec-20Pallet5320
934690D00AO14-Oct-20Jumbo5323
72M21001B17-Oct-20Pallet5323
100M21109B25-Nov-20Jumbo5323
6634690D00AO25-Nov-20Pallet5323
-934690D00AO14-Dec-20Pallet5323
-20M2611815-Dec-20Jumbo5323
9.634690D01AO18-Dec-20Pallet5323
9.0806442122CA26-Dec-20Pallet5323
934690D00AO01-Oct-20Pallet5325
16.234690D01AO22-Oct-20Pallet5325
60M2111223-Nov-20Jumbo5325
252M2611814-Dec-20Jumbo5325
130.234690D01AO14-Dec-20Pallet5325
-60M2611821-Dec-20Jumbo5325
-16.234690D01AO22-Dec-20Pallet5325
16.234690D01AO22-Dec-20Pallet5325
100M2111215-Oct-20Jumbo5328
47.434690D00AO26-Oct-20Pallet5328
-47.434690D00AO26-Nov-20Pallet5328
-100M2611817-Dec-20Jumbo5328
2434690D01AO21-Dec-20Pallet5328
176M21109B26-Dec-20Jumbo5328
47.434690D00AO26-Dec-20Pallet5328

 

Here's the sample intermediate calculation for calculating inventory levels on certain days (didn't include all days, because too many rows):

PlantJumboPalletDate
5320136.85018-Oct
5320136.856625-Oct
5320142.856625-Nov
5320122.856616-Dec
5320122.8515.218-Dec
5320122.8515.826-Dec
53239014-Oct
532397217-Oct
532310913825-Nov
532310912914-Dec
53238912915-Dec
532389138.618-Dec
532389147.6826-Dec
5325091-Oct
5325025.222-Oct
53256025.223-Nov
5325312155.414-Dec
5325252155.421-Dec
5325252155.422-Dec
5328100015-Oct
532810047.426-Oct
5328100026-Nov
53280017-Dec
5328071.421-Dec
5328176118.826-Dec

 

Here's the desired result:

 PlantTotal JumboTotal PalletTotal% Jumbo% Pallet
Oct53201915.94622377.980.6%19.4%
Nov53204141.519806121.568%32%
Dec53201383203494141814.197.5%2.5%
Oct53232791080135920.5%79.5%
Nov53238702556342625.4%74.6%
Dec532325943566.486160.4842.1%57.9%
Oct532503243240%100%
Nov5325480756123639%61%
Dec532544762347.86823.865.6%34.4%
Oct53281700284.41984.485.7%14.3%
Nov532830001185418572%28%
Dec53281776191.41967.490.3%9.7%

 

Thank you!

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have create a Inventory_on_date table by dax:

Inventory_on_date =
VAR MinDate =
    MIN ( 'Posting Table'[Posting date] )
VAR MaxDate =
    MAX ( 'Posting Table'[Posting date] )
VAR table1 =
    CROSSJOIN (
        VALUES ( 'Posting Table'[Plant Code] ),
        CALENDAR ( MinDate, MaxDate )
    )
VAR table2 =
    SUMMARIZE (
        table1,
        [Date],
        'Posting Table'[Plant Code],
        "Jumbo1",
            CALCULATE (
                SUM ( 'Posting Table'[Quantity] ),
                FILTER (
                    'Posting Table',
                    'Posting Table'[Storage Type] = "Jumbo"
                        && 'Posting Table'[Posting date] = EARLIER ( [Date] )
                )
            ),
        "Pallet1",
            CALCULATE (
                SUM ( 'Posting Table'[Quantity] ),
                FILTER (
                    'Posting Table',
                    'Posting Table'[Storage Type] = "Pallet"
                        && 'Posting Table'[Posting date] = EARLIER ( [Date] )
                )
            )
    )
RETURN
    SUMMARIZE (
        table2,
        [Date],
        'Posting Table'[Plant Code],
        [Jumbo1],
        [Pallet1],
        "Jumbo",
            SUMX (
                FILTER (
                    table2,
                    [Date] <= EARLIER ( [Date] )
                        && 'Posting Table'[Plant Code] = EARLIER ( 'Posting Table'[Plant Code] )
                ),
                [Jumbo1]
            ),
        "Pallet",
            SUMX (
                FILTER (
                    table2,
                    [Date] <= EARLIER ( [Date] )
                        && 'Posting Table'[Plant Code] = EARLIER ( 'Posting Table'[Plant Code] )
                ),
                [Pallet1]
            )
    )

 

1.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EY7HlvJxP9lCuqPBlCT0mdYBnbEMT5-5XgUJNb6SuD5N8g?e=mK8GQ9

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @v-deddai1-msft,

 

What do you mean by adding the attributes from the summary table? I currently have a slicer for storage location with 118 distinct values that I would like to include. Does this mean that for the inventory_on_date table, I would have to cross join storage location, plant code (11 values), and date (over 2 years of dates - 735 values), resulting in 954,030 rows?

Hi @Anonymous ,

 

Since your fact table does not contain continuous date columns, I have to use crossjoin to get continuous date columns. I am not clear about the logical relationship between your storage location and Plant Code. If you find this logical relationship, you can use dax directly add storage location to summary table .

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

@v-deddai1-msft 

Hi Dedmond, the storage location is a subdivision of plant code and you can derive plant code from storage location. So I guess I can just crossjoin storage location and date to get a continuous date column for each storage location. Then, I can derive plant code from storage location, which gives me about 87,000 rows, which is much less than the other. Does that sound like the best method?

Hi @Anonymous ,

 

It is all depending on your raw data.

 

Best Regards,

Dedmon Dai

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can add those attributes in the summary table. I don't suggest you use measure in this case. You need to create temporary table like above in every measure. This can make your measure look bloated and affect performance. Because every measure needs to compute this temporary table once.

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

@v-deddai1-msft 

Hi Dedmond,

that does work, but is there a way to do it in a measure? Because I also have other attributes, such as business classification and valuation class linked to each posting (was not included in sample data) and they're only in the posting table. I have slicers for those attributes and would like it to work on the jumbo/pallet calculation also, i.e. if I choose food as business classification on the slicer, I only want the jumbo/pallet classification done for the materials associated with food as business classification. Currently, when a new table is created, those slicers from the posting table won't work.

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have create a Inventory_on_date table by dax:

Inventory_on_date =
VAR MinDate =
    MIN ( 'Posting Table'[Posting date] )
VAR MaxDate =
    MAX ( 'Posting Table'[Posting date] )
VAR table1 =
    CROSSJOIN (
        VALUES ( 'Posting Table'[Plant Code] ),
        CALENDAR ( MinDate, MaxDate )
    )
VAR table2 =
    SUMMARIZE (
        table1,
        [Date],
        'Posting Table'[Plant Code],
        "Jumbo1",
            CALCULATE (
                SUM ( 'Posting Table'[Quantity] ),
                FILTER (
                    'Posting Table',
                    'Posting Table'[Storage Type] = "Jumbo"
                        && 'Posting Table'[Posting date] = EARLIER ( [Date] )
                )
            ),
        "Pallet1",
            CALCULATE (
                SUM ( 'Posting Table'[Quantity] ),
                FILTER (
                    'Posting Table',
                    'Posting Table'[Storage Type] = "Pallet"
                        && 'Posting Table'[Posting date] = EARLIER ( [Date] )
                )
            )
    )
RETURN
    SUMMARIZE (
        table2,
        [Date],
        'Posting Table'[Plant Code],
        [Jumbo1],
        [Pallet1],
        "Jumbo",
            SUMX (
                FILTER (
                    table2,
                    [Date] <= EARLIER ( [Date] )
                        && 'Posting Table'[Plant Code] = EARLIER ( 'Posting Table'[Plant Code] )
                ),
                [Jumbo1]
            ),
        "Pallet",
            SUMX (
                FILTER (
                    table2,
                    [Date] <= EARLIER ( [Date] )
                        && 'Posting Table'[Plant Code] = EARLIER ( 'Posting Table'[Plant Code] )
                ),
                [Pallet1]
            )
    )

 

1.PNG

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EY7HlvJxP9lCuqPBlCT0mdYBnbEMT5-5XgUJNb6SuD5N8g?e=mK8GQ9

 

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

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

@v-deddai1-msft 

Hi Dedmon, that only takes into account the inventory levels on the last day of the month, not daily inventory levels. I have continued the thread in this post: https://community.powerbi.com/t5/Desktop/Measure-using-current-inventory-measure-response/m-p/157440... as I'm not able to reply with anything besides a text or link.

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can try the following 5 measures:

Total Jumbo = CALCULATE(SUM('Table'[Quantity]),FILTER(ALLSELECTED(Dim_Date),Dim_Date[Date]<= MAX(Dim_Date[Date])),'Table'[Storage Type] = "Jumbo")+0

Total Pallet = CALCULATE(SUM('Table'[Quantity]),FILTER(ALLSELECTED(Dim_Date),Dim_Date[Date]<= MAX(Dim_Date[Date])),'Table'[Storage Type] = "Pallet")+0

Total = CALCULATE(SUM('Table'[Quantity]),FILTER(ALLSELECTED(Dim_Date),Dim_Date[Date]<=MAX(Dim_Date[Date])))

% Jumbo = [Total Jumbo]/[Total]

% Pallet = [Total Pallet]/[Total]

 

For more details, please refer to the sample pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EfHgP-6ymjhOt-eElIg0J5AB16pWEqFcEeYAe0c5ZMXvqw?e=BPsHbW

 

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

 

Best Regards,

Dedmon Dai

amitchandak
Super User
Super User

@Anonymous , not very clear, But try the calculation like

 

CALCULATE(
SUM('Table'[Quantity]),
FILTER(
ALLSELECTED('Date Table'),
'Date Table'[Date] <= max('Date Table'[Date])
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.