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.
Hello Community,
Am looking for a power query that would help me replace the null values highlighted to the last 3 months average i.e.(July to Dec 2023 = (June,May,Apr)/3
Would greatly appreciate your input to resolve.. thank you.
MMB
Hi @Anonymous,
Give this a go.
let
Last3Months = Number.Round( List.Average( List.ReplaceMatchingItems(
Table.SelectRows( Source, each Date.IsInPreviousNMonths([month_], 2) or Date.IsInCurrentMonth([month_]) )[ib_call_pct],
{{null, 0}} )), 4
),
Source = Table.FromColumns(
{
List.Transform( {1..12}, each #date( 2023, _, 1) ),
{.1655, null, .1442, .1506, .162, .0196, null, null, null, null, null, null}
}, type table[ month_ = date, ib_call_pct = Percentage.Type]
),
Replaced = Table.ReplaceValue( Source, each Record.ToList(_), each Record.ToList(_), (x, y, z)=> if (y{0} > Date.From( DateTime.FixedLocalNow()) and y{1} = null) then Last3Months else x, {"ib_call_pct"} )
in
Replaced
with this result
Ps. If this helps you solve your query, please mark it as solution. Thanks!
Check out the July 2025 Power BI update to learn about new features.