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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
cmncp
Helper III
Helper III

Summing last Inventory numbers across countries for different dates

I am trying to calculate an inventory number based on inconsistent data.  We have monthly inventory data being loaded for each multiple countries.  Each country loads their data at the beginning of the month, but on different days over a period of a week.  The inventory table will hold many months worth of history, but I need to calculate the current inventory number.  For some countries this will be the current month's, but for others I need to get last months.  I have created the following measure:

 

CALCULATE(
    sum(Inventory[Total Stock]),
    LASTNONBLANK ('Date'[FullDate], CALCULATE(COUNTROWS(Inventory))))

This works if all countries have entered their data for the month.  E.g. If I use the measure without a date, it returns the current months inventory number, but it also lets me use it with a date to show how the number changed over time. 

 

However, if I try and use it when only some of the countries have entered their data, it does not work correctly.  Take a look at the following:

2019-10-17_14-45-25.png

 

Looking at #1, you will see that only country TH has entered inventory data for October.  This is causing the Grand total to be wrong.  It should be the sum of the TH October number, plus the Sept totals for the other 3 countries.

 

Looking at #2, the total is wring again, because the filter using LASTNONBLANK is restricting the data to October.  Same thing for #3.

 

Does anyone know who to modify my measure to include the last month's inventory for each country when doing the totals?

0 REPLIES 0

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors