top of page

Excel Arena

This is the place, where we can test the boundaries of Excel functions.

Table.Pivot can pivot missing value in column - Power Query

Our source data includes columns for Product, Month, and Sales.

Sales occur in January, March, and April, meaning there are no sales recorded for February.

ree

The goal is to pivot the Month data into columns for all months, ensuring that the final table contains a column for February with null values.


In this post, I will show a simple method using the Table.Pivot function to achieve this.


let

 Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

 Result = 

 [

 Lst = List.Transform(Source[Month], (f) => Date.Month(Date.FromText(f&"0"))),

 fin = Table.Pivot(Source,List.Transform({List.Min(Lst)..List.Max(Lst)}, (f) => Date.ToText(#date(2000,f,1),"MMM")),"Month","Sales", List.Sum)

 ][fin]

in

 Result

Recent Posts

See All
Recursion in Excel and Power Query

In this post, I will demonstrate recursion in Excel and Power Query with some basic examples. Example 1: You are on a set of stairs that...

 
 
 
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Excel with Excel. Proudly created with Wix.com

bottom of page