- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Difference in Months - Columns
Hi all,
How can Power Query give the below required output:
Source Data:
Employee ID Employee Name Start Date End Date
2321 John Smith 01/05/23 31/12/23
Required Output:
Employee ID Employee Name Jan23 Feb23 Mar23 Apr23 May23 Jun23 Jul23 Aug23 Sep23 Oct23 Nov23 Dec23
2321 John Smith 1 1 1 1 1 1 1 1
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @henrys1995 - yes, absolutely. You can modify this part of the script to customize the format of the date.
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @henrys1995
Is the required out what you want to visualise after loading the data? If so try this.
Leave the data as it is and load it in. Are you using a Date Dimension Table? Then Try this
Hope it helps
Joe
Employee RT =
VAR _MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
DISTINCTCOUNT('Table'[Employee ID]),
KEEPFILTERS('Table'[Start Date] <= _MaxDate
&& 'Table'[End Date] > _MaxDate),
ALL('Date'))
Proud to be a Super User! | |
Date tables help! Learn more
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello - this is how you can do it in Power Query. Basically you would add a column which contains a list of months from the start to the end date, expand the list to rows and pivot it to columns.
Script
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFMIzs0syVDSUTI0MjYBUqb6hvpGBkbGYBF9YygnNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Employee = _t, ID = _t, #"Start Date" = _t, #"End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee", type text}, {"ID", Int64.Type}, {"Start Date", type date}, {"End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Transform ( List.Select ( List.Dates([Start Date], Number.From ( [End Date] ) - Number.From ( [Start Date] ),#duration(1,0,0,0)), each Date.Day ( _ ) = 1 ), each Date.ToText ( _, "MMMyy" ) ) ),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded Custom",{"Employee", "ID", "Custom"}),
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Other Columns", {{"Custom", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Other Columns", {{"Custom", type text}}, "en-US")[Custom]), "Custom", "Employee", List.Count)
in
#"Pivoted Column"
Result
FYI, when needing to show dates in columns instead of rows there is usually a better way of designing the solution, such as using a data table in the model.
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@jennratten thanks - is it possible have instead of MMMyy - have the first of each month so 01/01/24 as a date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi @henrys1995 - yes, absolutely. You can modify this part of the script to customize the format of the date.
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
07-07-2024 11:26 AM | |||
05-25-2024 09:58 AM | |||
10-14-2024 04:21 AM | |||
08-26-2024 08:55 PM | |||
08-27-2024 03:41 AM |
User | Count |
---|---|
27 | |
27 | |
25 | |
13 | |
10 |
User | Count |
---|---|
24 | |
19 | |
16 | |
13 | |
10 |