Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Solved! Go to Solution.
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.
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
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.
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
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 😀
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |