How to trim the decimal part from money field - asp.net-mvc

I have a View() with a link to make a payment. Link looks something like this
Pay Now
My problem is Model.Amount has the amount format like this 20.00 or 100.00 because the DataType is money and its adding extra zero's.
I need to remove the '.' so it reads 2000 or 10000.
How can I achieve that?

Related

Is there a Function or set of functions on Google Sheets that reacts every multiple?

Okay, say I have 5 cells. Each with varying amounts.
I want a function that: If(Sum(b2:b6) {greater or equal to a multiple}, True, False
So every time the total value of those cells is greater to or equal to a multiple of, say 50, so if it lands on 50n+1 or something, it'll react as if it hit 50n.
I guess you are not multiplying but adding numbers in range, since you are using "SUM" in function. In case, here is a solution:
=IF((SUM(B2:B6))>=50;TRUE;FALSE)
Note: This code is written with Norwegian format settings. Change ";" in formula with "," for American format settings.
sounds like:
=IF(SUM(B2:B6)>=50; 50; )

Remove $ Sign from importXML formula in Google Sheets

I have an issue with the IMPORTXML function and then changing the currency in my portfolio tracker.
IMPORTXML (C3=IMPORTXML(B3,"//div[#class='priceValue___11gHJ']") takes the price of a cryptocurrency from coinmarketcap (B3=https://coinmarketcap.com/currencies/ethereum/ - this all works fine (would rather prefer to have the prices from coingecko, but cannot figure the IMPORTXML function for that website... - if anyone has some valuable input for this too, would be great).
However, the imported price in C3 has a dollar sign before the actual numbers, which mess up the GOOGLEFINANCE formulas in columns D (D3=C3GoogleFinance("CURRENCY:USDEUR")) and E (E3=C3GoogleFinance("CURRENCY:USDGBP")). Screenshot of the error attached. Error Message
Does anyone know how to fix this?
Much appreciated!
Rob
On cell C3 you could use:
=VALUE(SUBSTITUTE(IMPORTXML(B3,"//div[#class='priceValue___11gHJ']"),"$",""))
References:
SUBSTITUTE
VALUE
If I understand correctly, the problem is that the imported price in C3 has a dollar sign in front of the actual numbers, which breaks down further processing by formulas.
To solve the problem, you can wrap the formula in C3 in a MID() formula that returns a segment of a string. If we specify a position number equal to 2, starting from which the string segment will be extracted, then the dollar sign at position 1 will be ignored. The sign of the pound or the euro will also be ignored - any currency sign with a length of 1 symbol.
10 is the segment length with some margin. Please note if the end of string is reached before segment length characters are encountered, MID returns the characters from starting position to the end of string.
C3:
=MID(IMPORTXML(B3,"//div[#class='priceValue___11gHJ']"),2,10)
MID()
Here's a little workaround to import the prices from coingecko, and remove the $ simbol, of course:
=SUBSTITUTE(IMPORTXML("https://www.coingecko.com/en/coins/ethereum"; "//div[contains(#data-controller,'coins-information')]//span[contains(#data-coin-symbol,'eth')]");"$";"")
But, as you can imagine, if they change the html structure of the site, this will stop working.
Have fun!

query about Excel formula - function

I have an issue with excel, lets say someone purchased something in (A1)100 dollars and i have to cut (B1)4.5 % of the said amount as tax. then when i want to insert the remaining amount after the deduction of tax(C1) that is (A1)-(B1). it shows 96 dollars. but actually it should be 95 dollars.
Check the format of the cell that has the result (C1). Make sure it is number and has two decimal places.

How do you sort an alpha-numeric list in excel?

I'm trying to sort a list of documents, but I'm having an issue with the documents that have a letter as a suffix.
Whenever we amend a document we add a letter to the end of the number, but when I sort by number in excel it sorts like this:
1
2
3
10
11
1606
1603D
1605B
1606A
1606C
1610A
1623A
20A
220B
390A
399A
402A
415A
450A
488A
557B
How can I make it sort in order of document number and amendment?
Like so:
1
2
3
10
11
1603D
1605B
1606
1606A
1606C
1610A
1623A
20A
220B
390A
399A
402A
415A
450A
488A
557B
As long as you have a mix of text and number, you won't be able to use Excel's built-in sort to achieve the result you describe.
If you append a letter to a number you effectively change the data type from number to text. Text will always be sorted after any number, hence the number 1606 comes before the text 1606A.
You could try to make all values real text, maybe indicate levels by appending digits with dots, like this:
1.
1.0.
1.1.
1.6.0.3.D
1.6.0.5.B
1.6.0.6.
1.6.0.6.A
1.6.0.6.C
1.6.1.0.A
1.6.2.3.A
2.
2.0.A.
2.2.0.B.
3.
3.9.0.A.
3.9.9.A.
4.0.2.A.
4.1.5.A.
4.5.0.A.
4.8.8.A.
5.5.7.B.
But even that does not give you the sort order you describe as the desired result.
Your desired sort order will be hard to achieve even if all values are text, or if you replace the A, B, C with a decimal .1, .2, .3. -- It's really hard to understand why 20 would come after 1623.
The solution I found was to add a column, and copy this formula into each cell:
=IF(ISNUMBER(--RIGHT(A2)),A2,LEFT(A2,LEN(A2)-1))
The formula removes the letters from the numbers, you can then sort your sheet using the new column of clean numbers.

Dynamically convert currency

I have a column of values in varying currencies. I want to create a column that automatically detects the currency of a given value and converts that to GPB (or any other given currency).
I have the following formula for querying the exchange rate:
=INDEX(GoogleFinance("eurgbp","price",date(2014,9,15)),2,2)
However this requires that you specify the currency you are converting from. I want this to be dynamic, because my list of currencies varies.
You can return a text string representation of a formatted value with:
=TO_TEXT(A1)
So if you have the value 35 formatted as British Pound Sterling, the formula will return the string:
£35.00
Now you can match that string with a lookup table (probably using REGEXMATCH) to return the string required for GoogleFinance(). The trouble is that the native format of, say, the US dollar, is exactly the same as, say, the Australian dollar. However, you can set your own custom number formats (eg with USD or AUD appended) that will be carried through to the TO_TEXT function.
So you would probably need to describe all your possible currency formats to arrive at a more specific solution.
Sounds like you'll need to come up with some kind of encoding for the currency column values. For example:
Currency
----------
USD, 10254 # $102.54
RMB, 1010 # ¥101.0
You'd then need to parse that column value somehow in order to determine the currency type. Or you could have two columns. One for currency type and the other for currency value:
Type Currency
---- --------
USD 10254 # $102.54
RMB 1010 # ¥101.0
By the way, the currency columns are integers so you don't have to use floating point math which is a nice thing to avoid in my experience.
As AdamL mentioned, you need to check if there are currencies with the same symbols in your list of data.
If not, you can do the following:
Amt Text Amt Symbol
=========================================
(data) =TO_TEXT(A2) =left(B2,FIND(REGEXEXTRACT(B2,"[0-9\.\,]"),B2)-1)
This will get your currency symbol from the column A. The formula is finding the first occurrence of something numeric (including . and ,) and then you just take what is on the left of it to obtain the currency.
Then you need a table for each symbol to its ISO 3 letter code so you can use Google Finance to obtain the FX, something like:
Symbol ISO Ccy
======================================
$ USD
£ GBP
€ EUR
Then you can get the ISO ccy by using VLOOKUP and continue the formulas above, here I did the FX for GBP
Amt Symbol FX Convert Amt
===================================================================================================
(formula above) =IF(D2="GBP",1,INDEX(GoogleFinance(D2&"GBP","price",<SOMEDATE>),2,2)) =E2*A2
I saved an example here.

Resources