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.
Table - DAily Avg
DateID | DailyAvg |
01/01/2020 | 500 |
01/07/2020 | 500 |
01/14/2020 | 500 |
01/21/2020 | 500 |
Table Inventory
DateID | Inventory |
01/01/2020 | 2000 |
01/02/2020 | 2222 |
01/03/2020 | 4566 |
01/04/2020 | 5632 |
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
Date | Inventory | 4 weeks avg |
01/01/2020 | 2000 | |
01/02/2020 | 2222 | |
01/03/2020 | 4566 | |
01/04/2020 | 5632 | 500 |
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
@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...
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]))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
46 | |
26 | |
22 | |
12 | |
8 |
User | Count |
---|---|
73 | |
51 | |
45 | |
16 | |
12 |