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
Anonymous
Not applicable

Conditional Dynamic Custom Column

Hai All, I need help with this requirement on this which we want to do in the power query editor.
Background 
I work on the sales dashboard, so every month users will send a new version table with the same schema, so I use the appending option for every month to append every table.
So based on this column we can assure the different versions which appending every month(Attaching below)


alanpjames_0-1654242923229.png

And now I want to create  one custom conditional  numerical column based on this 
Requirement
For 2021 versions will go like this format
V5-May-2021
V6-June-2021
V7-July-2021
V8-August-2021
V9-September-2021
V10-October-2021
V11-November-2021
V12-December-2021
based on 2021 data is ok but what about 2022 or Coming years it will be collapse
1st  requirement
So I want to create one custom numerical column that should only present numerical values
for eg. v5-may-2021 For the custom should only return 5
2nd requirement 
From the next year 2022
The custom column values should show like this 122 , 222, 322 , 422, etc(1 Is the version, 22 is the year)
From the next year 2023
The custom column values should show like this 123, 223, 323 , 423, etc(1 Is the version, 23 is the year)
So desired Custom column output 

Custom column 
8
9
10
11
12
122
222
322
 422




The top table from  8 to till 12 shows 2021 versions data and down it is showing next year's (2022) desired values 
and this should be dynamically created for every version.
Note:  this I want to do in power query as a custom column 

please help me to achieve this logic

1 ACCEPTED SOLUTION
tamerj1
Community Champion
Community Champion

Hi @AlanP514 

Here is the sample file with the solution https://we.tl/t-lkm4UtAKrG

https://we.tl/t-akHIBCeHpB

This the PQ code 

 

 

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\Tamer.Juma\TiSUN Dropbox\tamer tisunenergy\Tamer - Personal\Work\PBI Community\Community 2\Community 161.xlsx"), null, true),
    Versions_Sheet = Source{[Item="Versions",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Versions_Sheet, [PromoteAllScalars=true]),
    Version = Table.AddColumn(#"Promoted Headers", "Text Between Delimiters", each Text.BetweenDelimiters([Version], "V", "-"), Int16.Type),
    Year = Table.AddColumn(Version, "Text After Delimiter", each Text.AfterDelimiter([Version], "20"), Int16.Type),
    #"Change to Intiger" = Table.TransformColumnTypes(Year,{{"Text Between Delimiters", Int64.Type}, {"Text After Delimiter", Int64.Type}, {"Version", type text}}),
    #"Inserted Addition" = Table.AddColumn(#"Change to Intiger", "Addition", each [Text Between Delimiters] + 100 * [Text After Delimiter], Int16.Type ),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Addition",{{"Addition", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Text Between Delimiters", "Text After Delimiter"})
in
    #"Removed Columns"

 

View solution in original post

1 REPLY 1
tamerj1
Community Champion
Community Champion

Hi @AlanP514 

Here is the sample file with the solution https://we.tl/t-lkm4UtAKrG

https://we.tl/t-akHIBCeHpB

This the PQ code 

 

 

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\Tamer.Juma\TiSUN Dropbox\tamer tisunenergy\Tamer - Personal\Work\PBI Community\Community 2\Community 161.xlsx"), null, true),
    Versions_Sheet = Source{[Item="Versions",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Versions_Sheet, [PromoteAllScalars=true]),
    Version = Table.AddColumn(#"Promoted Headers", "Text Between Delimiters", each Text.BetweenDelimiters([Version], "V", "-"), Int16.Type),
    Year = Table.AddColumn(Version, "Text After Delimiter", each Text.AfterDelimiter([Version], "20"), Int16.Type),
    #"Change to Intiger" = Table.TransformColumnTypes(Year,{{"Text Between Delimiters", Int64.Type}, {"Text After Delimiter", Int64.Type}, {"Version", type text}}),
    #"Inserted Addition" = Table.AddColumn(#"Change to Intiger", "Addition", each [Text Between Delimiters] + 100 * [Text After Delimiter], Int16.Type ),
    #"Changed Type" = Table.TransformColumnTypes(#"Inserted Addition",{{"Addition", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Text Between Delimiters", "Text After Delimiter"})
in
    #"Removed Columns"

 

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 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.

Top Solution Authors