This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi All,
I have been struggling to build this measure, If [Occupancy %] is Blank for Select Date (21/11/2021) , then look into last three Dates, If [Occupancy %] exists in Last Three Dates then take into Calculation.
Average(95%, 75%, 88%) for 21/11/2021 is 86% .
| AREA | Date | Occupancy % |
| A | 21/11/2021 | 95% |
| B | 21/11/2021 | |
| C | 21/11/2021 | 75% |
| D | 21/11/2021 | |
| E | 21/11/2021 | 88% |
| A | 20/11/2021 | 97% |
| B | 20/11/2021 | |
| C | 20/11/2021 | 94% |
| D | 20/11/2021 | 92% |
| E | 20/11/2021 | 100% |
| A | 19/11/2021 | 97% |
| B | 19/11/2021 | |
| C | 19/11/2021 | 80% |
| D | 19/11/2021 | 96% |
| E | 19/11/2021 | 90% |
| A | 18/11/2021 | 100% |
| B | 18/11/2021 | 62% |
| C | 18/11/2021 | 63% |
| D | 18/11/2021 | 89% |
| E | 18/11/2021 | 98% |
| A | 17/11/2021 | 82% |
| B | 17/11/2021 | 88% |
| C | 17/11/2021 | 64% |
| D | 17/11/2021 | 71% |
| E | 17/11/2021 | 97% |
Desired Output for Date 21/11/2021:
Average(95%, 62%, 75%, 92%, 88%) = 82%
B and D are blank for 21/11/2021, so i have to take from previous available dates.
Thanks in Advance..
Solved! Go to Solution.
@Anonymous , use a date table
Last Day Non Continuous =
var _1 = calculate(max(Table[Date]) , filter(allselected(Table), [AREA] = max(Table[AREA]) && 'Table'[Date] < max('Date'[Date])))
return
if(isblank([sales]) , calculate(sales, filter(all('Date'), 'Date' =_1)), [sales])
@Anonymous , use a date table
Last Day Non Continuous =
var _1 = calculate(max(Table[Date]) , filter(allselected(Table), [AREA] = max(Table[AREA]) && 'Table'[Date] < max('Date'[Date])))
return
if(isblank([sales]) , calculate(sales, filter(all('Date'), 'Date' =_1)), [sales])
@Anonymous , Trya measure like below, with help from date table
Rolling 3 = if(isblank([Occupancy %]), CALCULATE(AverageX(values('Date'[Date]),[Occupancy %]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date])-1,-3,DAY)) ,[Occupancy %])
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Thanks for replying,
I dont want to calculate rolling,
I want to calculate the Average [Occupancy %] for Selected [Date] ,
But if [Occupancy %] is blank for Any [AREA] in the selected [Date] ,
then take previous Date [Occupancy %] to calculate the Average for Selected Date.
You can see in the Data that [AREA] B and D are blank for the Date 21/11/2021, in this case i need to take
[Occupancy %] for AREA B and D from previous Date 20/11/2021, or from 19/11/2021.
Thanks
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 27 | |
| 26 | |
| 22 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 45 | |
| 44 | |
| 41 | |
| 21 | |
| 18 |