Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have two sources of data (suppliers) that update product inventory data on different schedules. I would like know how much inventory is available (latest read).
Input data looks like this:
source | date | qty |
supplier 1 | 1/1/2021 | 4 |
supplier 1 | 1/9/2021 | 1 |
supplier 2 | 1/12/2021 | 10 |
Desired output would be a measure with the sum of the latest records for supplier 1 and supplier 2: 11 units (10+1)
This one works well with just one supplier:
Any help would be much appreciated
Solved! Go to Solution.
Hi @Javierco
You may try this Measure.
SumOfLatestRecords =
VAR LatestDate =
ADDCOLUMNS (
'Table',
"latest", CALCULATE ( LASTDATE ( 'Table'[date] ), ALLEXCEPT ( 'Table', 'Table'[source] ) )
)
RETURN
CALCULATE (
SUM ( 'Table'[qty] ),
FILTER ( LatestDate, 'Table'[date] = [latest] )
)
Then, the result will look like this.
Also, attached the pbix file as reference.
Best Regards,
Community Support Team _ Caiyun
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Hi @Javierco
You may try this Measure.
SumOfLatestRecords =
VAR LatestDate =
ADDCOLUMNS (
'Table',
"latest", CALCULATE ( LASTDATE ( 'Table'[date] ), ALLEXCEPT ( 'Table', 'Table'[source] ) )
)
RETURN
CALCULATE (
SUM ( 'Table'[qty] ),
FILTER ( LatestDate, 'Table'[date] = [latest] )
)
Then, the result will look like this.
Also, attached the pbix file as reference.
Best Regards,
Community Support Team _ Caiyun
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!
Hi @Javierco
Here is a sample file that contains the solution https://www.dropbox.com/t/G4SVVdi5t5w5tlMS
Basically, you need to create a new calculated column that retrieves the last order date per supplier for each record:
Last Date =
MAXX (
FILTER (
Data,
Data[source] = EARLIER ( Data[source] )
),
Data[date]
)
Then you can create a simple measure that performs SUMX over a filtered table:
Last Date Qty =
VAR LastDateTable =
FILTER (
Data,
Data[date] = Data[Last Date]
)
VAR Result =
SUMX (
LastDateTable,
Data[qty]
)
RETURN
Result
Hi Javierco,
Please Try This measure And let me know your Answer.
My Measure =
VAR _latest =
MAX ( 'Table'[Date] )
VAR _2nd_latest =
MAXX ( FILTER ( 'Table', 'Table'[Date] < _latest ), 'Table'[Date] )
VAR _FilterTable =
FILTER ( 'Table', 'Table'[Source] IN { "suppliar1", "suppliar2" } )
VAR _Result =
CALCULATE (
SUM ( 'Table'[qty] ),
FILTER (
_FilterTable,
'Table'[Date] IN DATESBETWEEN ( 'Table'[Date], _2nd_latest, _latest )
)
)
RETURN
_Result
Hi,
Try something like this:
var _date = MAX('Calendar'[Date])
var _latestdate = CALCULATE(MAX('Table'[Date]),ALL('Table'[Date]),'Table'[Date]<=_date)
Return
CALCULATE(SUM('Table'[qty]),ALL('Table'[Date]),Table[Date]=_latestdate)
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/
Proud to be a Super User!
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |