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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

add conditional column

Hello!

I have this table. Relevant for us are the columns [Nummer], [Saldo] and [Date].

 

For each Month there is 1 row in [nummer]. I just want to add a column [saldo previous month] where it takes the corresponding value from [saldo] from the same [nummer] from last month.

 

I've made an example in the picture below.

sunny_marco_0-1668173478054.png

 

Can somebody help me to add this conditional column? I really don't get it how to code this column. 

Thank you!

Marco

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

1. add a custom column like:

vcgaomsft_0-1668417876075.png

2. merge queries:

vcgaomsft_1-1668417913751.png

3. expand and rename [Saldo] column:

vcgaomsft_2-1668418071319.png

    #"Added Custom" = Table.AddColumn(#"Umbenannte Spalten", "Custom", each Date.AddMonths([Date],-1)),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Nummer", "Custom"}, #"Added Custom", {"Nummer", "Date"}, "Sorted Rows", JoinKind.LeftOuter),
    #"Expanded Sorted Rows" = Table.ExpandTableColumn(#"Merged Queries", "Sorted Rows", {"Saldo"}, {"Saldo.1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Sorted Rows",{"Custom"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Saldo.1", "saldo previous month"}})
in
    #"Renamed Columns"

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

View solution in original post

7 REPLIES 7
negi007
Community Champion
Community Champion

@Anonymous can you share your sample pbix file




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

can you please help me with this? @negi007 

Anonymous
Not applicable

Yes, I can't upload files yet. It's only possible to share links so I saved it on a onedrive link:

 

https://1drv.ms/u/s!ArzXZfC_jkl3gch6T5Ssb4Rjue6Cww?e=WFEqrf

Anonymous
Not applicable

Hi @Anonymous ,

1. add a custom column like:

vcgaomsft_0-1668417876075.png

2. merge queries:

vcgaomsft_1-1668417913751.png

3. expand and rename [Saldo] column:

vcgaomsft_2-1668418071319.png

    #"Added Custom" = Table.AddColumn(#"Umbenannte Spalten", "Custom", each Date.AddMonths([Date],-1)),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Nummer", "Custom"}, #"Added Custom", {"Nummer", "Date"}, "Sorted Rows", JoinKind.LeftOuter),
    #"Expanded Sorted Rows" = Table.ExpandTableColumn(#"Merged Queries", "Sorted Rows", {"Saldo"}, {"Saldo.1"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Sorted Rows",{"Custom"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Saldo.1", "saldo previous month"}})
in
    #"Renamed Columns"

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

Thank you very much, yeah it worked 🙂 Actually way more easy than i thought before!  

Unfortunately I can't log in in the account i posted this before, thats why I can't directly accept it as a solution 😕

ToddChitt
Super User
Super User

I think this would be better served by a DAX Measure. And [Nummer] is strictly a dimension of your data.




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





i did it with dateadd:

Saldo Last Month = CALCULATE(SUM(ER_und_Bilanz[Saldo]),VALUES(ER_und_Bilanz[Nummer]),DATEADD(ER_und_Bilanz[Date],-1,MONTH))

 

But I'm working with a slicer, and then the month before must also be selected that it works. thats why i thought a want to add a column where the data from last month is already inside. so i only have to select one month

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.