Formula to sum up formatted cells with commas - excel

I'd like to sum up all the formatted D2:D6 cells and print this info in total
---------------------------
D2 | January | 1,000 |
---------------------------
D3 | February | 2,000 |
---------------------------
D4 | March | 3,000 |
---------------------------
D5 | April | 400 |
---------------------------
D6 | May | 500 |
---------------------------
D7 | Total | 6,900 |
---------------------------
I tried to apply this formula, but it gave me an error:
=SUM(VALUE(REPLACE(D2:D6;FIND(",",D2:D6;1),1;"")))

Just sum the range.
If the range is not numbers, but text that looks like numbers, the question is: why is that so? Why would a number be turned into text?
To insert a thousand comma?? That can be done with number formatting without destroying the number data type.
the data was downloaded like that from a report? Use Power Query to load the report and clean up the data in Power Query. Then you can use simple Excel formulas.
If none of the above are viable options, the final resort can be a formula, like
=SUMPRODUCT((SUBSTITUTE(D2:D6,",","")+0))
Your sample formula suggests that your regional settings use the semicolon to separate parameters in Excel, so you need this:
=SUMPRODUCT((SUBSTITUTE(D2:D6;",";"")+0))
Edit: Another variant that will not break if a cell in the range is blank or contains text that cannot be converted to a number:
=SUMProduct(IF(ISNUMBER(SUBSTITUTE(D2:D6,",","")+0),SUBSTITUTE(D2:D6,",","")+0,0))
the semicolon version:
=SUMProduct(IF(ISNUMBER(SUBSTITUTE(D2:D6;",";"")+0);SUBSTITUTE(D2:D6;",";"")+0;0))
With this construct you can also use Sum() instead of SumProduct() but note that for non 365 versions of Excel the Sum() variant the formula needs to be confirmed with Ctrl+Shift+Enter.
Cleaning the data up with Power Query might be a lot easier than using formulas like that for simple calculations like totaling numbers.

Related

Extracting all information(different) with same row name form a excel worksheet using formula

I have a excel workheet having a table with multiple rows having same name with different information in the corresponding columns. Now using a formula I want to extract this infomation into a new table? SOLUTION HAS TO BE USING AN EXCEL FOMULA ? NO FILTERS NO PIVOT TABLE OR VBA
I have tried vlookup. to search for multiple values. I dont want information from a single column but rather from all the columns. There could be thousands of columns with same and different values.
I have tried this formula : =INDEX(Worksheet!A2:AK350;KKLEINSTE(WENN((A5=Worksheet!A2:A350);VERGLEICH(ZEILE(Worksheet!A2:A350);ZEILE(Worksheet!A2:A350));"");1))
The table looks like this for example:
Place People Salary Status
japan | resident_1 | 564 | un-married
Delhi | resident_1 | 655 | un-married
china | resident_1 | 564 | un-married
japan | resident_2 | 748 | un-married
Now I want to extract a sub table from the above, like all the
infomation having PLACE name as "japan"
the reult should be this for each place in a different table:
japan | resident_1 | 564 | un-married
japan | resident_2 | 748 | un-married
Seems like a job for advanced filter, but you've already stipulated "no filters". If you're able to add two helper columns in your main table, maybe you can use the approach below.
This is my main_table worksheet (note the columns outlined in red, which have been added).
The formula in column E (starting from cell E2) is: =CONCAT(A2,"|",B2,"|",C2,"|",D2)
The formula in column F (starting from cell F2) is: =ROW()-ROW($F$2)+1
Drag/fill these formulas down to the last row in your main table.
This is my sub_table worksheet (note the cells outlined in green at the top, where you will eventually specify filter criteria).
The formula in column A (starting from cell A5) is: =ROW()-ROW($A$5)+1
The formula in column B (starting from cell B5) is: =IFERROR(SMALL(IF(ISNUMBER(SEARCH($B$2,main_table!$E$2:$E$10)),main_table!$F$2:$F$10,""),$A5),"")
The formula in columns C, D, E, F (starting from cell C5) is: =IF(ISNUMBER($B5),INDEX(main_table!$A$2:$D$10,$B5,COLUMNS($C5:C5)),"")
The formula in cell B2 is: =CONCAT(IF(ISBLANK($C$2),"*",$C$2),"|",IF(ISBLANK($D$2),"*",$D$2),"|",IF(ISBLANK($E$2),"*",$E$2),"|",IF(ISBLANK($F$2),"*",$F$2))
You should drag the formula down for the same number of rows that are in your main table.
I think newer/upcoming versions of Excel have a JOIN worksheet function which is more convenient/flexible than my usage of CONCAT above (so maybe use that if it's available to you).
Leaving the filter criteria blank should give you all rows. If you want partial matches, include wildcards in your input e.g. jap* or resident_*. If any of the values in your main table contain a |, you may want to use a different delimiter in the CONCAT formulas (otherwise you may get unexpected results/behaviour).
Once you're done, maybe you can use it like shown below:
See if this approach is any good for you (you will probably need to translate the formulas to your locale/region).

Use Excel SUMIF to add cells with custom number formatted dollar value

I have a range of cells that contain dates and dollar amounts. I'd like to total the cells with dollars.
The worksheet is formatted in columns like this:
Date | Amount |Date | Amount | ... for about 20 col.
| | | |
| | | |
| | | |
I've tried various versions of SUMIF but I can't get a formula that will ignore the dates and include the dollar values. The dollar value cells have a custom number format that includes a $ sign. But I haven't been able to get anything that can use the $ to distinguish the 2 types of cells. Any suggestions?
The actual numerical value may be useful but it will depend upon the nature of your data (which is conspicuous by its absence).
A day is 1. A Date is 1 for every day past 31-Dec-1899. Today happens to be 42,537 and one year ago was 42,171. If no valid amount was larger than $40,000 then you can reliably use the SUMIF or SUMIFS function by discarding numerical amounts greater than EDATE(TODAY(), -12).
=sumif(a:z, "<"&edate(today(), -12), a:z)
=sumifs(a:z, a:z, "<"&edate(today(), -12))
Note the syntax differences between SUMIF and SUMIFS.
Another approach would be comparing the column header labels in a SUMPRODUCT function.
=sumproduct((a1:z1="amount")*a2:z999)
Do not use full column references with SUMPRODUCT. Always restrict your data ranges to the extents of your actual data.

How to use arrayformula to indicate an occurrence in google sheets

I'm trying to write an =arrayformula that finds the 1st, 2nd, 3rd, etc. occurrence of a value in another column. I can do this with a formula copied down all rows but I don't want to use this method, I need the arrayformula to simply always update the column because I need to constantly insert and delete rows and I don't want to have to keep copying the formula down. Thanks in advance.
Google sheet where I'm testing this.
Example formulas that I currently have to copy down..I want this to simply be an arrayformula instead:
values | occurance
aa | =if(A3<>"",countif($A$3:$A3,A3),"") | RESULT:1
2 | =if(A4<>"",countif($A$3:$A4,A4),"") | RESULT:1
aa | =if(A5<>"",countif($A$3:$A5,A5),"") | RESULT:2
5 | =if(A6<>"",countif($A$3:$A6,A6),"") | RESULT:1
5 | =if(A7<>"",countif($A$3:$A7,A7),"") | RESULT:2
4 | =if(A8<>"",countif($A$3:$A8,A8),"") | RESULT:1
Formulas that work but have to be copied down
Check out cell D3 where I used this formula:
=ArrayFormula(iferror(SORT(ROW(A3:A),SORT(ROW(A3:A),A3:A,1),1)-MATCH(A3:A,SORT(A3:A),0)-ROW()+2))
and see if that works for you ?

Excel VLookup #NV error

I'm trying to make a VLookup in Excel but I get everytime a #NV error.
This is table EVENTS:
This is table TRACK:
the formula on field F2 in table EVENTS is
=SVERWEIS(E2;TRACKS!$A$2:$B$52;1;FALSCH)
SVERWEIS is the word for VLOOKUP in the German version. FALSCH means wrong
As has been mentioned, VLOOKUP (SVERWEIS) can only look to its right to find a value to correspond with a value in the left hand columns of a table. The INDEX/MATCH combination is more flexible in this respect so if not to rearrange your columns I would suggest something like:
=INDEX(A:A,MATCH(E2,B:B,0))
where TRACK is assumed to be in ColumnsA:B. Converting to German, perhaps:
=INDEX(TRACKS!A:A;VERGLEICH(E2;TRACKS!B:B;0))
VLOOKUP compares the values in the first column of your reference target, you have your target values in the second.
Just swap VLOOKUP and the TEXT columns on your TRACKS sheet and it will work just fine.
Try switching the columns in TRACKS around.
VLOOKUP bases it's lookup on the first column, so in your case, it's looking through column A (1, 2, 3, etc.)
If you want your VLOOKUP to be based on the text, it needs to be in A instead.
i.e.
| A | B |
----------------------
1 | TEXT | VLOOKUP |
2 | Text1 | 1 |
3 | Text2 | 2 |
etc...
Then your function will be:
=SVERWEIS(E2;TRACKS!$A$2:$B$52;2;FALSCH)
Switching out the third argument because you now want the value from the second column

SUM/IF Statement with Text input and a Numeric Sum output in Excel

Ok, I am having trouble with this equation. I have (4) rows for text entries that have a numeric association depending on what you input. The equation I have does not SUM all four rows. With each text input of "I"=100,"P"=86,"N"=63 with a sum dependant on what was input.
=SUM(IF(A4:D4="I",100)+IF(A4:D4="P",86)+IF(A4:D4="N",63,0))
I should have the number 400 in E4 with "I" entered in A4:D4, or 344 in E4 with "P" entered in A4:D4.
Thank you for any help you can give.
KC
You can also do this with an "Array" Formula like so
=SUM((A1:D1="I")*100,(A1:D1="P")*86,(A1:D1="N")*63)
You have to enter this with Ctrl-Shift and Enter, and it will be enclosed in curly brackets.
Look up "Array Formulas" for details, they're a pain to get your head around but will save you a lot of extra columns.
Can take a while to calculate on a large sheet mind.
You can insert values in adjacent cells: (I will transpose the data for simplicity of formatting)
| A | B |
1 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
2 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
3 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
4 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
Then in E4 you have : SUM(A1:A4)

Resources