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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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]))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors