Converting a post number into a negative

Vegas01

New Member
Joined
Jun 15, 2021
Messages
43
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone

I was wondering is there anyway to convert the numbers with a CR to a negative while leaving the rest to a positive. I am currently working in Power Query.

Thanks in advance

1625451719355.png
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try
Replace $ with -
Then Replace CR with "" / nothing
Change data type to a numeric one eg currency
 
Upvote 0
Alex

Thanks for help but that did not work. The formula is below, I have a thought that it has something to do with the data type of the column which is currently "Any" I have change the data type to a couple of different things but it did not work. Any suggestions?

= Table.AddColumn(#"Filtered Rows", "Custom.1", each if [Inc GST] = "$" then "-" else [Inc GST])
 
Upvote 0
See if this works for you.
If your Filtered Rows is the last step before the final "in" statement then you may just be able to copy this in after the Filtered Rows replacing your current in statement.
I have assumed you are using en-US just change the last 2 characters if that is not the case.

Power Query:
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Filtered Rows", "Text Between Delimiters", each Text.BetweenDelimiters(Text.From([Inc GST], "en-US"), "$", "C"), type text),
    #"Added Conditional Column" = Table.AddColumn(#"Inserted Text Between Delimiters", "Custom", each if [Text Between Delimiters] <> "" then -Number.FromText([Text Between Delimiters]) else [Inc GST])
in
    #"Added Conditional Column"

I will try to walk you through what I did.
1) Add 1st Column
Select Inc GST column
Add Column > Extract > Text Between Delimiters
Start delimiter = $
End delimiter = C

2) Add 2nd Column
2.1) Select new column "Text Between Delimiters"
Add Column > Conditional Column
if Text Between Delimiter is empty / blank (see below) then use that value else use the Inc GST value
2.2) Modify the M Code
Change what you see between the "then" and the "else"
from: then [Text Between Delimiters] else
to: then -Number.FromText([Text Between Delimiters]) else
(NOTE: the minus sign at the start before Number.From)

*** additional clean up steps ***
3) Change Data Type to Decimal or Currency as required
4) Remove columns no longer required
5) Rename Custom column to Inc GST
1625539447737.png
 
Upvote 0

Forum statistics

Threads
1,223,707
Messages
6,174,000
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top