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
gardas_swathi
Microsoft Employee
Microsoft Employee

Display sum only for max Inventory available date

Table - DAily Avg

DateIDDailyAvg
01/01/2020500
01/07/2020500
01/14/2020500
01/21/2020500

Table Inventory

DateIDInventory
01/01/20202000
01/02/20202222
01/03/20204566
01/04/20205632

I have a requirement where i have to calculate 4 weeks average value and display the value only against the latest inventory date. Future Dates and past dates should show blank. If there is no selecion on Date , then it should display the 4 week average too

Expected Output when filtered on date

DateInventory4 weeks avg
01/01/20202000 
01/02/20202222 
01/03/20204566 
01/04/20205632500

 

Expected Output when there is no selection on date

4 weeks avg
500

Measure i have developed so far is not giving the expected result. It shows values for previous dates as well.

 VAR DateSelection = SELECTEDVALUE('Date'[Calendar Date])
VAR Tab1 =  SUMMARIZE (
            'DailyAvg',
               " Final", CONVERT (
                SUM ( 'DailyAvg'[DailyAvg] )/28,
                DOUBLE
            )  ) 
   VAR Tab2= ADDCOLUMNS(Tab1,"InventoryDate",MAX('Inventory'[DateID]))
  VAR Val = SUMX(Tab2,[Consensus Final])
   VAR MDate= MAX('Inventory'[DateID]
RETURN IF(DateSelection=[MAxInventoryDate] OR DateSelection=BLANK() , result,BLANK())

 

Please help. Thanks in Advance

3 REPLIES 3
amitchandak
Super User
Super User

@gardas_swathi , refer if my Week blog can help, it uses week rank. The rolling formula is available in blog or comments

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

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

HI Amit,

 

Thanks for your response. my Data model already has daily average calculated and its populated from the source . I am able to get the avg for the 4 weeks. Its straight forward in my scenario. SUM(DailyAvg)/28

 

All i need to do is display this value based on the inventory max availability date.  If the inventory max date is 9/2 i need to display the value for that date

@gardas_swathi , not very clear. But you can get data for the last available date. But will not work when day is axis or group, then you need use allexcept

 

lastnonblankvalue(Table[Date],sum([Value]))

 

calculate( lastnonblankvalue(Table[Date],sum([Value])),allexcept (Table[Week]))

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
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.