cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lcfaria
Helper I
Helper I

Replicate values for the next year - Power Query/DAX

Hi all,

 

I need help, I have a table with some values for my current year (in this example it is year 2015) and I would like to replicate all values from 2015 to year 2016 by adding 10%.

 

I would like to do this using Power Query if possible, but it could be with DAX as well.

lcfaria_0-1653682631537.png

 

Example download link: https://1drv.ms/u/s!At5JlMR_naI1gf4y5TmX0kd625M3aw?e=BdI8ri



2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@lcfaria 

I created a new table using DAX as follows and I think it should be fine for you.

Fact Result =
UNION (
    'fact - Issue',
    SELECTCOLUMNS (
        ADDCOLUMNS ( 'fact - Issue', "New Value", 'fact - Issue'[Value] * 1.1 ),
        "Date", EDATE ( 'fact - Issue'[Date], 12 ),
        "Name", 'fact - Issue'[Name],
        "Value", [New Value]
    )
)

Fowmy_0-1653683806225.png

 





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

tomfox
Community Champion
Community Champion

Hi @lcfaria ,

 

How about this:

tomfox_0-1653684203827.png

 

 

You can paste the following M code into the advanced editor:

tomfox_1-1653684254887.png

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NTJR0lRyA2NDBQitVBk3ACYiNsEs4gHaYICSNcRhnhMsoIw6hYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Value = _t]),
#"Add One Year" = Table.ReplaceValue(Source,each [Date],each Date.AddYears([Date], 1),Replacer.ReplaceValue,{"Date"}),
#"Value times 1.1" = Table.ReplaceValue(#"Add One Year",each [Value],each [Value] * 1.1,Replacer.ReplaceValue,{"Value"}),
#"Appended Query" = Table.Combine({Source, #"Value times 1.1"}),
#"Changed Type" = Table.TransformColumnTypes(#"Appended Query",{{"Date", type date}, {"Name", type text}, {"Value", Int64.Type}})
in
#"Changed Type"

 

Let me know if this helps or if you get stuck somewhere 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

View solution in original post

3 REPLIES 3
lcfaria
Helper I
Helper I

@tomfoxand @Fowmy thanks for the answers, both solutions worked for me 😊

tomfox
Community Champion
Community Champion

Hi @lcfaria ,

 

How about this:

tomfox_0-1653684203827.png

 

 

You can paste the following M code into the advanced editor:

tomfox_1-1653684254887.png

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUByIjA0NTJR0lRyA2NDBQitVBk3ACYiNsEs4gHaYICSNcRhnhMsoIw6hYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Name = _t, Value = _t]),
#"Add One Year" = Table.ReplaceValue(Source,each [Date],each Date.AddYears([Date], 1),Replacer.ReplaceValue,{"Date"}),
#"Value times 1.1" = Table.ReplaceValue(#"Add One Year",each [Value],each [Value] * 1.1,Replacer.ReplaceValue,{"Value"}),
#"Appended Query" = Table.Combine({Source, #"Value times 1.1"}),
#"Changed Type" = Table.TransformColumnTypes(#"Appended Query",{{"Date", type date}, {"Name", type text}, {"Value", Int64.Type}})
in
#"Changed Type"

 

Let me know if this helps or if you get stuck somewhere 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/

Fowmy
Super User
Super User

@lcfaria 

I created a new table using DAX as follows and I think it should be fine for you.

Fact Result =
UNION (
    'fact - Issue',
    SELECTCOLUMNS (
        ADDCOLUMNS ( 'fact - Issue', "New Value", 'fact - Issue'[Value] * 1.1 ),
        "Date", EDATE ( 'fact - Issue'[Date], 12 ),
        "Name", 'fact - Issue'[Name],
        "Value", [New Value]
    )
)

Fowmy_0-1653683806225.png

 





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors