Not sure if I'm overlooking something but I can't seem to find an answer for this. I have two sheets:
Sheet 1
country | cost
---------------------
DE | 5
FR | 4
US | 3
MX | 2
AT | 1
Sheet 2
region | country
---------------------
EU | DE
EU | FR
AM | US
AM | MX
EU | AT
What I want is the sum of cost of all European Countries. In the past I simply used a column C with VLOOKUP for the region in Sheet 1 and then SUMIF'd this data. I'd like to avoid this, because the volume of data in Sheet 1 is huge and dynamic.
I could of course use
=FILTER(Sheet2!country, Sheet2!region="EU")
which would return an array of {"DE", "AT", "FR"}, but I cannot use
=SUMIF(Sheet1!cost, Sheet1!country=FILTER(Sheet2!country, Sheet2!region="EU"))
Is there an alternative to this?
Maybe you are looking for something like this:
=ArrayFormula(sum(sumif(A:A,filter(Sheet2!B:B,Sheet2!A:A="EU"),B:B)))
Then, replace the VLOOKUP with an INDEX MATCH,
=IFERROR(INDEX(Sheet2!$A$2:A$6, MATCH(A3, Sheet2!$B$2:B$6, 0)))
where col B in sheet 2 are the countries, and col A the region
In order to use VLOOKUP you would have to change the lay-out of sheet 2 so that it has country in col 1 and region in col 2
Then you can use VLOOKUP in col C of first sheet
=VLOOKUP(A3, Sheet4!$A$2:$B$6, 2)
Drag down as far as needed
And for the sumif:
=sumif(C3:C7, "EU", B3:B7)
Related
Background: Here is the data I am using for the Power BI visualization. You may also be able to view this link and download the excel file from replit. https://replit.com/join/tzsvuaqktb-iamyolanda
I am attempting to analyze metrics by date. In this case, the sum of the fruits.
Normally I can use a measure and group it by categories in a visualization. For example, you can have a measure = count([column A]) that you group by fruit type.
Fruit | count fruits eaten
———————————————-
Banana | 10
Apple | 5
Peach | 21
Total | 36
Now my problem is that when I apply filters, it no longer works…
If I filter my measure like this =CALCULATE(SUM(["Number of Fruits"]), ["Date Eaten"]=DATE(2022,11,20)
Then the table results like this
Fruit | count fruits eaten
———————————————-
Banana | 4
Apple | 4
Peach | 4
Total | 4
Where 4 is the sum of everything, instead of what was expected
How do I filter my measure and still get it to group properly???
What I tried:
CALCULATE(COUNT("Number of Fruits]), [Date Eaten]=DATE(2022,11,20))
But this measure will not group in my table visualization.
I have a human-friendly sheet with sparse data:
PART | FRUIT
---------------
Alpha |
| Apples
| Pears
Beta |
| Lemons
| Oranges
I want to create a second automatically updated machine-friendly sheet, which would have all empty cells in column PART filled:
PART | FRUIT
---------------
Alpha |
Alpha | Apples
Alpha | Pears
Beta |
Beta | Lemons
Beta | Oranges
I am OK to have empty cells in the column FRUIT on the machine-friendly sheet. But ideally I would like such rows removed:
PART | FRUIT
---------------
Alpha | Apples
Alpha | Pears
Beta | Lemons
Beta | Oranges
If I wanted to use interpolation in the machine-friendly sheet, I would rely on the MATCH trick or the FILTER paste-anywhere formula.
But I really want to avoid updating the machine-friendly sheet when I add, change or remove rows in the original sheet. (I'm OK if I will have to update it if I add new columns to the original sheet.) This means that using manual interpolation is off-limits.
Ideally on the second sheet I would type in a magic ={ARRAYFORMULA()} or a =QUERY of some kind, and then leave it alone.
={ ARRAYFORMULA(MAGIC(PART)), FRUIT }
But so far I cannot wrap my head on how to approach this. Any suggestions?
use in row 2:
=ARRAYFORMULA(IF(B2:B="",, VLOOKUP(ROW(A2:A), IF(A2:A<>"", {ROW(A2:A), A2:A}), 2, 1)))
Hopefully someone can help me with a google sheets formula to look up a currency in a column of currency pairs, I'm sure it's fairly basic but because it needs a partial match as the news will always be a single currency and the list of pairs will always be two currencies put together I am struggling to do this.
How my sheet is structured; I have a list of currency pairs in one column, the next column is what I'm trying to do. In the "news ?" column the value = "News" if the previous currency pair matches with any the values in H20 to H25. The value = "No News" if the currency pair does not contain any values in H20 to H25. In this example, these values are AUD and CAD as we have news on these currencies today to be wary of.
1 | Currency pairs | News ?
2 | AUDUSD | News
3 | EURUSD | No News
4 | GBPUSD | No News
5 | USDCAD | News
6 | USDCHF | No News
7 | USDJPY | No News
8 | AUDCAD | News
9 | AUDCHF | News
10 | AUDJPY | News
11 | AUDNZD | News
12 | AUDSGD | News
13 | CADCHF | News
14 | CADJPY | News
15 | CHFJPY | No News
etc...
And I have a column of currencies which has news occurring today e.g.
H19 | Today we have news on
H20 | AUD
H21 | CAD
H22 |
H23 |
H24 |
H25 |
My question is: How do I highlight via a formula if one part of the currency pair appears in the news column. Can be conditional formatting or a value in the next column as per the example which says "News" or "No News" (or 1 or 0, tick or cross, doesn't really matter as long as it flags if it matches with the news)
The tricky part is the currency pairs column will always be the six character pairs and the news column will always just be one single three-letter currency.
The news column will have anywhere between 0 news and say 5 rows of currencies which have news
I have tried things like this with no success so far:
=VLOOKUP(H20:H25&"*",A2,1,0)
=IF(REGEXMATCH(A2, H20:H25&"*"), 1, 0)
=if(COUNT(find(H20:H25,A2))=1,CHAR(10004))
formula in B2 cell:
=ARRAYFORMULA(IF(REGEXMATCH(A2:A15, TEXTJOIN("|", 1, A20:A25)), "News", "No News"))
custom conditional formatting formula:
=REGEXMATCH($A2, TEXTJOIN("|", 1, $A$20:$A$25))
In Power BI I have some duplicate entries in my data that only have 1 column that is different, this is a "details" column.
Name | Value | Details
Item 1 | 10 | Feature 1
Item 1 | 10 | Feature 2
Item 2 | 15 | Feature 1
Item 3 | 7 | Feature 1
Item 3 | 7 | Feature 2
Item 3 | 7 | Feature 3
I realize this is an issue with the data structure, but it cannot be changed.
Basically, when I sum up my Value column on a Power BI card, I only want it to sum for each unique name, so in this case:
Total = 10 + 15 + 7
I will be using the details in a matrix, so I cannot simply remove the duplicates from within the Query Editor.
Is there any way I can filter this with a DAX formula? Just summing the first occurrence of an item?
You can create a measure as follows:
Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))
It will return the first non-blank Value for all distinct Name and sum it up.
Results:
This must help
Table = SUMMARIZE(Sheet2,Sheet2[Item],"Sales Quantity",SUM(Sheet2[Sales Quantiy]),"Purchase Quantity",CALCULATE(SUMX(DISTINCT(Sheet2[Purchase Quantity]),FIRSTNONBLANK(Sheet2[Purchase Quantity],0))))
I want to create a data validation list that changes in size depending on 2 criteria. The sheet looks like this:
A | B | C
1 | 1 | 100
2 | 0 | 200
3 | 1 | 300
4 | 1 | 400
5 | 0 | 500
6 | 1
7 | 1
Column A is the reference number of a loan
Column B is an activation cell (1 = loan is activated, 0 = loan is not activated)
Column C is the loan amount
I want to create a validation list that shows the reference number of the loans that are activated (i.e. Column B = 1) AND that have a value in Column C (i.e. Column C is not blank).
I managed to create the validation list that adjusts itself for the blank cells, but I don't know how to account for Column B as a second criteria.
A VBA code to do this would also be helpful!
A simple formula in Column D copied to all cells below with show you a validated column with TRUE beside the valid rows
=IF(B2,IF(C2,TRUE,""),"")
looks like