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
Thiago_Font
Regular Visitor

Duplicate rows based on criterias

Hi, I've searched the forum and didn't find any solution that looks like with my issue.

 

I have a data set of accruals by month, and the amount needs to be reversed in the following month i.e:

 

NameMov.TPMonthAmount
FreightAccrual1100
FreightRevesal2-100

 

What I'm trying to do is the following

"if mov.TP"="Accrual" then Month +1 and Amount *(-1) and Mov.TP="Reversal".

 

I tried to merge the columns into rows and created some calculated columns but the number of rows grew exponentially due to the nuumber of columns in the table.

 

Thanks in advance for any help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Thiago_Font ,

 

You can add three custom columns in Power Query Editor.

vstephenmsft_0-1673428730176.pngvstephenmsft_1-1673428736068.png

vstephenmsft_2-1673428750508.png

vstephenmsft_3-1673428767131.png

You can download my attachment for more details.

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Thiago_Font ,

 

You can add three custom columns in Power Query Editor.

vstephenmsft_0-1673428730176.pngvstephenmsft_1-1673428736068.png

vstephenmsft_2-1673428750508.png

vstephenmsft_3-1673428767131.png

You can download my attachment for more details.

 

 

Best Regards,

Stephen Tao

 

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

wdx223_Daniel
Super User
Super User

=Table.FromRecords(List.TransformMany(Table.ToRecords(PreviousStepName),each if [#"Mov.TP"]="Accural" then {_,_&[#"Mov.TP"="Reversal",Month=[Month]+1,Amount=[Amount]*-1]} else {_},(x,y)=>y))

HotChilli
Super User
Super User

I think you could do this by duplicating the table, filter to keep only the "Accrual" rows and add custom columns for the values required (Month, amount, mov.tp ) - these columns will need a different name but you can create them, remove the original columns and then rename to get what you want).

You can then append this table with the original table.

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.

Top Solution Authors