Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Leo64
New Member

Year interval

Hello,

 

I have 3 year intervals:

 

2020 - 2024

2025 - 2029

2030 - 2034

 

I would like to transform it to:

2020

2021

2022

2023

2024

2025 

etc. until 2034

 

How can I accomplish this?

 

Thank you in advance.

 

Leo

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Leo64 ,

 

If you want to implement it in Power Query Editor, please refer to the following command.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjIwMtAFEiZKsTpgnimIZwnlGYPkjIFysQA=", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Year = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Year", type text}}), 
  #"Inserted Text Before Delimiter" = Table.AddColumn(
    #"Changed Type", 
    "Text Before Delimiter", 
    each Text.BeforeDelimiter([Year], "-"), 
    type text
  ), 
  #"Inserted Text After Delimiter" = Table.AddColumn(
    #"Inserted Text Before Delimiter", 
    "Text After Delimiter", 
    each Text.AfterDelimiter([Year], "-"), 
    type text
  ), 
  #"Renamed Columns" = Table.RenameColumns(
    #"Inserted Text After Delimiter", 
    {{"Text Before Delimiter", "StartYear"}, {"Text After Delimiter", "EndYear"}}
  ), 
  #"Changed Type1" = Table.TransformColumnTypes(
    #"Renamed Columns", 
    {{"StartYear", Int64.Type}, {"EndYear", Int64.Type}}
  ), 
  #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [EndYear] - [StartYear]), 
  #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom", {{"Custom", Int64.Type}}), 
  #"Added Custom1" = Table.AddColumn(
    #"Changed Type2", 
    "Custom.1", 
    each List.Numbers([StartYear], [Custom] + 1, 1)
  ), 
  #"Expanded Custom.1" = Table.ExpandListColumn(#"Added Custom1", "Custom.1"), 
  #"Removed Columns" = Table.RemoveColumns(
    #"Expanded Custom.1", 
    {"Year", "StartYear", "EndYear", "Custom"}
  )
in
  #"Removed Columns"

Attached PBIX file for reference, you can observe each step in APPLIED STEPS on the right.

vcgaomsft_0-1652950880642.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Leo64 ,

 

If you want to implement it in Power Query Editor, please refer to the following command.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText("i45WMjIwMtAFEiZKsTpgnimIZwnlGYPkjIFysQA=", BinaryEncoding.Base64), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Year = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"Year", type text}}), 
  #"Inserted Text Before Delimiter" = Table.AddColumn(
    #"Changed Type", 
    "Text Before Delimiter", 
    each Text.BeforeDelimiter([Year], "-"), 
    type text
  ), 
  #"Inserted Text After Delimiter" = Table.AddColumn(
    #"Inserted Text Before Delimiter", 
    "Text After Delimiter", 
    each Text.AfterDelimiter([Year], "-"), 
    type text
  ), 
  #"Renamed Columns" = Table.RenameColumns(
    #"Inserted Text After Delimiter", 
    {{"Text Before Delimiter", "StartYear"}, {"Text After Delimiter", "EndYear"}}
  ), 
  #"Changed Type1" = Table.TransformColumnTypes(
    #"Renamed Columns", 
    {{"StartYear", Int64.Type}, {"EndYear", Int64.Type}}
  ), 
  #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each [EndYear] - [StartYear]), 
  #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom", {{"Custom", Int64.Type}}), 
  #"Added Custom1" = Table.AddColumn(
    #"Changed Type2", 
    "Custom.1", 
    each List.Numbers([StartYear], [Custom] + 1, 1)
  ), 
  #"Expanded Custom.1" = Table.ExpandListColumn(#"Added Custom1", "Custom.1"), 
  #"Removed Columns" = Table.RemoveColumns(
    #"Expanded Custom.1", 
    {"Year", "StartYear", "EndYear", "Custom"}
  )
in
  #"Removed Columns"

Attached PBIX file for reference, you can observe each step in APPLIED STEPS on the right.

vcgaomsft_0-1652950880642.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

speedramps
Super User
Super User

You seem to have rushed this description.  😀

You will get a quicker resposne if you take time to include propoer input data examples. Thank you  😀

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.