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
Jo_Chrq
Helper I
Helper I

Change a dimension according to date

Hi all,

I'm facing an issue here :

In my store table, I have a field that classifies stores in subsidiary or franchise.

One store will change from Fra to Sub in April and I would like it to appear in the Fra report before April and in Sub after April.

Is there a way to do so?

Many thanks in advance

Jo

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Jo_Chrq ,

 

I think you can add this code in advanced editor to replace "Subsidiary" to "Franchise" if [Store] = xxx and [Date] >= 2022/04/01.

...,
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","Subsidiary",each if [Store] = "A" and [Date]>=#date(2022, 4, 1) then "Franchise" else [Category],Replacer.ReplaceText,{"Category"})
in
    #"Replaced Value"

Sample:

1.png

Result is as below.

2.png

The whole M code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMDLSNzDWNzAEcoJLk4ozUzITiyqVYnWQ5U2wyjvB5Q0h8m5FiXnJGZnFqWBpZwLGu6Abj6Q9FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Store = _t, Date = _t, Category = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Store", type text}, {"Date", type date}, {"Category", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","Subsidiary",each if [Store] = "A" and [Date]>=#date(2022, 4, 1) then "Franchise" else [Category],Replacer.ReplaceText,{"Category"})
in
    #"Replaced Value"

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Jo_Chrq ,

 

I think you can add this code in advanced editor to replace "Subsidiary" to "Franchise" if [Store] = xxx and [Date] >= 2022/04/01.

...,
#"Replaced Value" = Table.ReplaceValue(#"Changed Type","Subsidiary",each if [Store] = "A" and [Date]>=#date(2022, 4, 1) then "Franchise" else [Category],Replacer.ReplaceText,{"Category"})
in
    #"Replaced Value"

Sample:

1.png

Result is as below.

2.png

The whole M code.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIyMDLSNzDWNzAEcoJLk4ozUzITiyqVYnWQ5U2wyjvB5Q0h8m5FiXnJGZnFqWBpZwLGu6Abj6Q9FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Store = _t, Date = _t, Category = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Store", type text}, {"Date", type date}, {"Category", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","Subsidiary",each if [Store] = "A" and [Date]>=#date(2022, 4, 1) then "Franchise" else [Category],Replacer.ReplaceText,{"Category"})
in
    #"Replaced Value"

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

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.