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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Custom Column

Hai All I need your Full support On this 
Scenario : I  Have Sales table and users will send every new version on month basis.
I have a forecast version column like this |

alanpjames_0-1654668722263.png

And every month i am appending new version with previous one 
Requirment is i want to create one Custom column for previous version as dynamically
For eg : Now let's Assume latest version is V6-June-2021 and i want to create a dynamic custom column in power query or deskptop

 Out put should be like this 
Latest Version V7-June-2021
Previous Version V6-June-2021
Latest Version V6-june-2021
previous Version V5-May-2021

1 ACCEPTED SOLUTION

@Anonymous 
Sorry for the late reply. I got involved with some other business. Here is the sample file with the solution https://www.dropbox.com/t/dDXhM0NNwthWhfEy

Actually I allways prefer DAX. I find it much more simple than PQ. However, as along as you need this to be part of your source data please use the following M code

= Table.AddColumn(#"Promoted Headers", "Previous Version", 
each if Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) -1 = 0 
then "V12-December-" & Number.ToText( Int64.From(Text.AfterDelimiter([Forcast Version], "-", 1)) - 1 ) 
else  "V" & Number.ToText( Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) - 1 ) 
& "-" & Date.MonthName (#datetime ( 2020, Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) - 1, 01,0,0,0 )) 
& "-" & Number.ToText( Int64.From(Text.AfterDelimiter([Forcast Version], "-", 1)) - 1))

1.png

View solution in original post

5 REPLIES 5
tamerj1
Community Champion
Community Champion

Hi @Anonymous 

1.png

Do you mean "July"?

Anonymous
Not applicable

Sorry , it's My mistake
V7-July-2021

@Anonymous 
Sorry for the late reply. I got involved with some other business. Here is the sample file with the solution https://www.dropbox.com/t/dDXhM0NNwthWhfEy

Actually I allways prefer DAX. I find it much more simple than PQ. However, as along as you need this to be part of your source data please use the following M code

= Table.AddColumn(#"Promoted Headers", "Previous Version", 
each if Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) -1 = 0 
then "V12-December-" & Number.ToText( Int64.From(Text.AfterDelimiter([Forcast Version], "-", 1)) - 1 ) 
else  "V" & Number.ToText( Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) - 1 ) 
& "-" & Date.MonthName (#datetime ( 2020, Int64.From(Text.BetweenDelimiters([Forcast Version], "V", "-")) - 1, 01,0,0,0 )) 
& "-" & Number.ToText( Int64.From(Text.AfterDelimiter([Forcast Version], "-", 1)) - 1))

1.png

Anonymous
Not applicable

Hai @tamerj1 Can you  try to create same solution in dax format, this solution is working 

amitchandak
Super User
Super User

@Anonymous ,

Create a new column in DAX (on in power query)

 

Date = datevalue(right([version], len([version]-1) )

 

Now create a rank

Rank  = rankx(Table, [Date],,desc, dense)

 

now

flag for latest

if([Rank] =1 1, "Latest", [Rank])

 

these column can be used Rank can also used to find by adding +1

 

refer examples, I have used -1 as I have desc rank (Custom Period)

 

DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.