Cell References in Cube Formula - Excel PowerPivot - cube

I'm looking to run a CUBEVALUE formula with member expressions based on the contents of multiple different cells. For this example i have 2 cells with a value for REGION in:
I15: Border
I16: Midlands
I can reference one cell successfully using a cube value formula:
=CUBEVALUE("PowerPivot Data","[Measures].[Sum of WEIGHTED_IMPRESSIONS]","[pvtBASE].[REGION].&["&I$15&"]")
Couldn't find a way within CUBEVALUE alone to replicate this result to reference both I15 and I16 so tried with a CUBESET then referencing the CUBESET in a later CUBEVALUE formula:
For the CUBESET, this formula works:
=CUBESET("PowerPivot Data",{"[pvtBASE].[REGION].&[Midlands]","[pvtBASE].[REGION].&[Border]"})
This formula works:
=CUBESET("PowerPivot Data","[pvtBASE].[REGION].&["&I15&"]")
But for some reason this doesn't:
=CUBESET("PowerPivot Data",{"[pvtBASE].[REGION].&["&I15&"]","[pvtBASE].[REGION].&["&I16&"]"})
Does anyone know how to fix the final CUBESET formula or if perhaps there is another way of fitting multiple members and cell references into a CUBEVALUE formula.
Feels like i'm close but then again I might not be!
Cheers

Quotation marks go on the outside of the brackets rather than around each member. This works with AdventureWorks tabular model:
=CUBESET("AWCube","{[Sales Territory].[Sales Territory Group].["& G17 & "],
[Sales Territory].[Sales Territory Group].[" & G18 &"]}","TEST")
So your formula would be:
=CUBESET("PowerPivot Data","{[pvtBASE].[REGION].&["& I15 &"],
[pvtBASE].[REGION].&["& I16 &"]}")
The last argument in my cubeset formula is a name, which is optional. I give the cubeset a name so I can see it. Otherwise, the name comes back as blank and I forget that it is in that cell.

Related

How to use COUNTIFS based on multiple criteria over different sized ranges?

I have an attendance tracker in which I'm trying to account for each employee type per day.
I have a summary page (sheet1) in which I want the count of each type (A,B,C,D,E) based on the day in cell C2 whether or not they have an X on sheet2 for that day.
Using =COUNTIF(FILTER(Sheet2!$A$5:$GG$969,Sheet2!$A$5:$GG$5=$C$2),"X") I am able to get a total of "X" based on the date in cell C2.
However, I'm having trouble getting the formula to work counting each employee type.
=COUNTIFS(Sheet2!A5:AM31,A7,(FILTER(Sheet2!A5:AM31=C2)),"X")
This gives me an error "Array arguments to COUNTIFS are of different size."
I'm not sure how else to configure this. Below is a link to my sample sheet:
Appreciate any help!
https://docs.google.com/spreadsheets/d/1OdJTwbFsNcR1hO1qzMBGUY4iXcWgDwIAJmBAVE9cs0k/edit?usp=sharing
I think this would work, dragged down for the other groups.
=COUNTIFS(Sheet2!A$6:A$31,A7,FILTER(Sheet2!$6:$31,Sheet2!$5:$5=C$2),"X")
However, I would encourage you to look at this sample sheet (a copy of yours) where I've added a new tab called MK.Help, designed to be hidden, but used as a sort of helper tab to make all sorts of things you might like to do easier. Including the count you asked about.
It has one single formula in cell A2 where you can see what it does.
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(Sheet2!C5:5&"|"&Sheet2!A6:A31&"|"&Sheet2!B6:B31&"|"&Sheet2!C6:31),"|",0,0),"where Col3<>'' order by Col1"))
try:
={"", ""; QUERY(FILTER(Sheet2!A6:A31, FILTER(Sheet2!6:31, Sheet2!5:5=C2)="X"),
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''");
"Total", COUNTA(IFNA(FILTER(Sheet2!A6:A31, FILTER(Sheet2!6:31, Sheet2!5:5=C2)="X")))}

Excel: Using a formula (no VBA) how to check if elements in a range are in another array which is defined by index/match

I'd have another question. The situation is as follows: I have two tables (=formatted Excel tables). The situation looks as below. I am trying to filter for the $ sales amount (cell E4) of a given sales rep (cell D4). I was thinking about using =SUMPRODUCT(IF((Table2[Store ID]=INDEX(Table1[Store ID],MATCH("Marc",Table1[Sales Rep],0),)),1,0)) (as I would have other conditions such as month which are no displayed in my example below), however, that's not giving me the correct value. The index-formula gives me just the first result once it finds "Marc".
The "correct" result in the example shown would be $121 as Marc accounts for these sales in the store with ID 1.
How can I overcome this problem? Any help would be much appreciated.
Add an additional column [shop ok] with a formula =IF(F7=$D$4,[#[store ID]],0) into Table1, to indicate that this store is under Marc's control.
In E4 insert a formula
=SUMPRODUCT(Table2[Sales]* COUNTIF(Table1[shop ok],Table2[Store ID]))
It's an array formula, so add it using Ctrl+Shift+Enter
didn't manage to avoid adding additional columns, got some errors, so ended up with this solution for now.
In E4, enter formula :
=SUMPRODUCT(SUMIFS(I7:I9,H7:H9,D7:D9)*(F7:F9=D4))

How to pass addresses to Vlookup based on cell values (Google Sheets)

This has me stumped, so I'm hoping somebody who knows the proper functions can help me out.
I am trying to do a VLOOKUP, but I want to pass the Range in based on values in columns.
The Range is on a different sheet than where the formula is, and I want the range's start column to be determined by looking for the value that is at the top of the column the forumla exists in.
For example, in the attached image, the 'Dashboard' sheet has Column A as Sheet, and the top Row has Widgets and Sprockets in the top row.
I want the Formula to be a Lookup for the search key 'Total, and return the value in the cell next to it. I want the Range to start on the sheet specified in Column A, and the Column to be the one with the value that matches the one at the top of the column where the formula is.
So my formula will look like
=VLOOKUP("Total",<INSERT RANGE HERE>,2)
Help would be appreciated.
Link to the Google Sheet:
https://docs.google.com/spreadsheets/d/1H5At3gHeTQUm6PWqeA7MT5xcm5RJ38NK6LyhSWUeaZY/edit?usp=sharing
Thanks Stack Overflow Community
I believe this is what you're looking for.
On the Dashboard sheet enter these formulas:
C3:
=vlookup("Total", indirect($A3&"!C1:D"),2)
D3:
=vlookup("Total", indirect($A3&"!C1:F"),4)
You can then select C3:D3 and drag down to autofill. I tried using an arrayformula and it didn't work, but I might have been doing it wrong
Also make sure to change "Position1" and "Position2" to match the sheet names exactly.
Edit: I just saw your screenshot. These formulas can also be put into C2 and D2, I just put them next to the sheet names to keep track of what I had to do.
Edit in response to comment:
This was the closest I could get to what you're looking for.
C3:
=vlookup("Total", indirect($A3&"!C1:"&ADDRESS(ROW(INDIRECT($A3&"!$C50")),COLUMN()+1)),2)
D3:
=vlookup("Total", indirect($A3&"!E1:"&ADDRESS(ROW(INDIRECT($A3&"!$E50")),COLUMN()+1)),2)
Again, these columns can be dragged and autofilled down with no issues.
I have the following formula that can be pasted onto the dashboard C3 cell, and then copied across: =address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3) This will give me the address I want from the Sheet I am trying to reference, i.e. Position01!$C$1 Also, If I use the following formula, I get the value I want as a result: =offset(Position01!$C$1,7,1,1,1) However, If I try to combine the two, I get the error 'Argument must be a range'. =offset(address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3),7,1,1,1)
You need to add INDIRECT in front of the first formula when placing it inside of the OFFSET one so that it reads the result address as a range instead of a string:
=offset(INDIRECT(address(1,match(C$1,indirect($A3&"!1:1"),0),,,$A3)),7,1,1,1)
use:
=INDEX({VLOOKUP("Total", Position01!C:F, {2, 4}, 0);
VLOOKUP("Total", Position02!C:F, {2, 4}, 0)})
update:
if your project consists of 24 rows but unknown number of columns then you can use range:
Position01!C1:24 (instead of Position01!C:F)
then to return every column you can do:
COLUMN(Position01!C1:1)-1 (instead of {2, 4})
or if you want to return every 2nd column:
FILTER(COLUMN(Position01!C1:1)-2, MOD(COLUMN(Position01!C1:1), 2)=0)
(instead of {2, 4})

EXCEL: Create Array Formula out of INDEX/MATCH with multiple results

my aim is to convert a massive excel sheet with different projects, employees and hours worked per month into an overview per employee. It should be possible to display the projects the employee is involved in and how many hours he worked per project per month.
The original sheet looks something like this:
I managed to find the projects Person A worked in by filtering through the INDEX/MATCH function. I applied the formula to the whole row where the employees are listed and receive multiple results of projects. My question is how to transform the formula into something more effective to copy all of the matched results (projects) into a column (see 1).
This is what I have so far, if matches the employee name in a certain area; the output is the first match of the project he is involved in:
=INDEX(B2:J3;1;MATCH("Person A";Sheet1!B3:E3;0))
How can I copy this to the bottom cells to copy all of the matched results? Does it help to create an array formula with this?
You can use he following formula in cell B9:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$8,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
It indexes row 2 and looks for the column number of the first match in row 3 that equals the value in B8 (=Person A). When dragging down it will look for the second match ROWS(A$1:A1) will become ROWS(A$1:A2) = 2.
For Person B you can use this formula in cell B14:
=IFERROR(INDEX($2:$2,SMALL(IF($3:$3=$B$13,COLUMN($3:$3)-COLUMN(INDEX($3:$3,1,1))+1),ROWS(A$1:A1))),"")
I hope this is what you where looking for.
PS
if you paste the following formula in cell C9 you will get the sum result for Person A on Project XY in month 10 2019:
=IF(OR($B9="",C$8=""),"",SUMPRODUCT(($B$2:$K$2=$B9)*($B$3:$K$3=$B$8)*($A$4:$A$6=C$8),B4:K6))
Note: That is provided that the value in cell C8 equals the value in cell A4.

Vlookup from multiple criteria to display nearest answer

I was hoping someone can help me. I have hit a solid wall.
I have a table with product information included and I am building a calculator which should spit out a number of options based on set criteria which is in the table. I am failing at just pulling through a code. I feel rather embarassed asking about how to do a vlookup here. But basically I have a vlookup which depends on multiple criteria and for the calc to cough out the nearest match (if applicable) based on this criteria.
Criteria 1 = Product
Criteria 2 = Type
Criteria 3 = Height
Criteria 4 = Min
I have created a search key in the table to concatenate all of these columns and then done a vlookup, which is =Vlookup(Criteria1 & Criteria2 & Criteria3 & Criteria4, Table Data, Code Required) But this does not appear to be giving me results, it either coughs out an error or the incorrect product. Below is my data and my calc I am hoping to complete. Can someone please help?
Here is an example looking for a closest match on Min. It demonstrates the principle so you can extend.
The closest match formula part is:
MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0))
Column E for column with Min values in. And K2 for target Min. This is an array formula entered with Ctrl + Shift+Enter. You would adjust the range of E2:E4.
The multiple criteria part is using:
=MATCH(lookup_value_1&lookup_value_2&lookup_value_3, lookup_array_1&lookup_array_2&lookup_array_3, match_type)
Where you are concantenating your parameters and searching for a match of the concatenation of those parameters in the table (you could do this against the key column if the key is made up of the same parameters.)
Overall formula with some test data (using one estimate figure):
=INDEX(F:F,MATCH(K1&K5&J5&INDEX(E2:E4,MATCH(MIN(ABS(E2:E4-K2)),ABS(E2:E4-K2),0)),B:B&C:C&D:D&E:E,0))
Above entered combined formula remember is an array formula so entered with Ctrl+Shift+Enter . You can reduce the ranges from entire columns to only those rows holding data.
Data data:
I am not typing all that out from picture so here is a quick n dirty
I tried with the QHarr's solution but it didn't work with all the rows.
My solution is:
Add a column with:
=IF(E2 < $K$2, E2, 0) and copy for all rows
In L5 create the formula:
{=INDEX(F2:F19,MATCH($K$1&K5&$J$5&INDEX(E2:E19,MATCH(MAX(SI(B2:B19=$K$1,1,0)*IF(C2:C19=K5,1,0)*IF(D2:D19=$J$5,1,0)*G2:G19,0),E2:E19,0)),B2:B19&C2:C19&D2:D19&E2:E19,0))}
Copy the formula to L6 and L7
Excel exercise printscreen
Originally marked this as answered and it did work initially but as I added more products it began to fail. I did manage to (after much trial and error) find a simple solution {=INDEX(Calc!$I$2:$I$189,MATCH(Output!$H$7,IF(Calc!$B$2:$B$189=Output!A12,Calc!$H$2:$H$189),1))}

Resources