Second Ordered set is not ordered - excel-2010

In an Excel OLAP Pivot I have the following custom set called "EventsOrdered":
ORDER(
{[DimensionEvents].[Events].[Event].members},
SUM (
TAIL([Date].[Date - Calendar Month].[Calendar Month].members, 12),
[Measures].[Revenue]
),
BDESC
)
When I add it as the second column to the pivot I get the following:
What it is ordering the events by is World revenue but I want the order of the events to be partitioned by the country e.g the yellow row should be higher up the order for the US.
Is this possible? - how do I change the MDX script to reflect this context aware behavior in Excel- I've unsuccessfully played around with some tuples that use the CURRENTMEMBER function like the following but no joy:
ORDER(
{[DimensionEvents].[Events].[Event].members},
SUM (
(
[Date].[Date - Calendar Month].CURRENTMEMBER,
[Geolocation].[Geography].CURRENTMEMBER
),
[Measures].[Revenue]
),
BDESC
)

did you try the following?:
ORDER(
{[DimensionEvents].[Events].[Event].members},
SUM (
TAIL([Date].[Date - Calendar Month].[Calendar Month].members, 12),
[Measures].[Revenue],
[Geolocation].[Geography].CURRENTMEMBER
),
BDESC
)
philip,

no you don't need to;
it's the correct answer !
Philip,

Related

Lookup/Query confusion - Really stuck but I figure it's not as hard as I'm making it

So, I have an imported sheet with colums like so...
Name
SAT1045
SAT1200
Dave
0
1
Angela
0
1
Stuart
1
0
From this I need to generate attendance lists displaying the times (SAT1045) followed by those attending. Those attending have a 1 in that column. So as a example:
SAT1045
Stuart
SAT1200
Dave
Angela
The other trick is there are multiple days and times, so I have used Data Validation to populate a dropdown on a fresh sheet. So the chosen date would populate the list below it.
I just don't know what Query or Lookup function to use to strip the data from the import as there is also a lot of nonsene data in the import between the Names and the dates.
Can anyone help?
I have tried numerous levels of Query's and Lookups but my head just can't get around this one
I would recommend you to use a second sheet for the attendance.
If the Name cell in your exemple is A1, you cvan have someting like this in your second sheet:
In A1 (second sheet) :
=Sheet1!B1
this will set the header at the corresponding time
In A2 (second sheet) :
=QUERY(
Sheet2!$A$1:$C$4,
CONCATENATE("select A where ",SUBSTITUTE(ADDRESS(1,COLUMN(B2),4),1,""),"=1")
,0
)
this will get the names for the time set in the first row.
Than tou only hace to drag those to for every attendance to get.
Edited to adjust to OP's comment
=QUERY(
[table of time and 0/1],
CONCATENATE(
"select A where ",
SUBSTITUTE(
ADDRESS(
1,
COLUMN(
INDEX(
[Row with all times],
match(
[Reference of the cell with the dropdown],
[Row with all times],
0
)
)
),
4
),
1,
""
),
"=1"
),
0
)
this formula here allow you to get the attendants based of the time in the cell above it.
So, from the left to the right :
match here will look through the different time based on the selected one in the cell above, and will return the reference of the cell;
The whole part Substitute(Adress(Column(Index()))) will return the letter of the column in wich the selected tim is. this allow to have a valid Query as it requiress the letter of the column to work;
And finally the Query returns every name where the value is 1 in the column corresponding to the chosen time
The values of [Row with all times] should always be the same. In your case, either 1:1 or $AC$1:$AP$1. In the first case it's just that if you add a row for a new time it'll take it into acount

How to use a SUM formula using an input from another sheet with an address function?

I am trying to SUM every number in a range on a different sheet. This range is dictated by an employee number, as well as the year; it changes for each employee and it also changes every year.
So I need the sum function to work like this:
​=sum(first cell:second cell)
With the cells being variable with each employee.
I had used the ADDRESS function to obtain the cell values, but it put the sheet name between apostrophes, e.g. ​'sheetx!'!A1 , which I thought caused the sum function to return an error.
To test this, I made a test SUM function using input from the CELL function, which returns the sheet value without apostrophes (e.g. ​sheetx!A1​). I still got an error.
What am I doing wrong?
Edit: filter did not seem to work for me, but the index and indirect combo worked like a charm
Functions like INDEX, OFFSET,INDIRECT return the value as well as the range reference. So, you could use something like
=SUM(
INDEX(Sheetx!A:A,1,1)
:
INDIRECT(ADDRESS(1,2,1,1,"Sheetx"))
)
Note however, INDEX and OFFSET are preferred over INDIRECT as string ranges are better avoided to help internal optimization of spreadsheet.
Agree with #Harun24hr, try with the following:
=SUM(
FILTER(
FILTER( history_earnings!1:1000, history_earnings!A:A=B2 ),
MATCH( COLUMN( history_earnings!1:1000 ),
FILTER( COLUMN( history_earnings!1:1 ), history_earnings!1:1=A1 ),
0
)
)
)
you use ADDRESS that returns a string and then you join your two strings with a colon : but that is still a string not a valid range. try:
=SUM(INDIRECT("history_earnings!"&
ADDRESS(MATCH(B$2, history_earnings!$A:$A, ),
MATCH($A$1, history_earnings!$A$1:$Z$1, ))&":"&
ADDRESS(MATCH(B$2, history_earnings!$A:$A, ),
MATCH($A$1, history_earnings!$A$1:$Z$1, )+11)))
also, in your question, you mention: 'sheetx!'!A1 which is also wrong due to two exclamation marks ! correct being: 'sheetx'!A1 unless your sheet is called sheetx!

COUNTIFS unpredictably returns Zero

I am trying to grab advertising expenses for the day on the basis of country groups.
The date, and country for the record are in columns I, J and G respectively.
I am doing a VLOOKUP that references a sheet called advertising,
with the search key being a date and month together, and picking up the value column based on the country.
Then in order to average it out, I am dividing this lookup, which gives me the ad spend for a set of countries by the number of records for that date, month and country.
=(IF(OR(G4="Spain",G4="Portugal"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,32,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"}),0),
IF(G4="France",VLOOKUP(I4&J4,Advertising!$A$3:$AK,33,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"}),0),
IF(G4="Italy",VLOOKUP(I4&J4,Advertising!$A$3:$AK,34,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"}),0),
IF(OR(G4="Belgium",G4="Netherlands"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,35,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"}),0),
IF(G4="Sweden",VLOOKUP(I4&J4,Advertising!$A$3:$AK,36,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"}),0),
IF(G4="United Kingdom",VLOOKUP(I4&J4,Advertising!$A$3:$AK,37,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"}),0),
VLOOKUP(I4&J4,Advertising!$A$3:$AK,31,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"}),0)
)))))))
Unfortunately, this is returning an error for me.
As you can see, I have an IF clause to avoid division by zero.
However, I have somehow convinced myself that the error is being reurned in the averaging (i.e. division with the COUNTIFS) process, not in the VLOOKUP. I do believe my COUNTIFS are illegitimately and unexplainably returning zero.
e.g. for row 4 in the main sheet, which I have posted above,
=COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})
returns a zero. When I test it out with fewer countries, always including Austria, sometimes it returns zero, sometimes 1.
A sample sheet is at https://docs.google.com/spreadsheets/d/1YgK_D7FaTWtKcSts2uDiG7jlTRx2_IGrJ41wZr2qyak/edit?usp=sharing
P.S. I do not have enough reputation, but I would request one of the seniors to add "countifs" tag.
try in row 4:
=INDEX(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!B3:AK},
MATCH(G4:G, Advertising!A1:1, ), )))
update:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK}, MATCH(IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )))))))
or like this:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK},
MATCH(IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )),
I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )))))))
Use match(), like this:
=arrayformula(
iferror(
vlookup(
I4:I & J4:J,
{ Advertising!B3:B & Advertising!C3:C, Advertising!B3:AK },
match(G4:G, Advertising!A1:AK1, 0),
false
)
)
)
See the new Solution sheet in your sample spreadsheet. The formula is in cell P4.
Note that not all the country names in your search keys are present in the data.

Merge Columns without deleting or affecting the rows

Im seeking some experienced advice, as I have been working on a little project to automate how we gather data in my office using Google Sheets(Please note that I can't use add-ons).
I'm encountering difficulties in finding a way to merge columns that have the same name, but without deleting/merging the row(because im pulling stats for the different tasks employees handle).
In the example you can see that column A has names that repeat because each individual completes one or more tasks, so my goal would be to find a way to automatically merge the repeating names in column A without affecting the rest of the columns.
I believe it is important to know that the table auto-populates as im currently using a filter function, because I paste all my data in the excel and it filters only my agents names.
Here is the formula that im using in c26:
=FILTER(A3:G22,ARRAYFORMULA(ISNUMBER(MATCH(A3:A22,{"Mary";"Jason";"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},0))))
Please tell me that there is a way to do this!
Here is a link to the example Doc That I made
https://docs.google.com/spreadsheets/d/1RsCeHfzzbRsUDnj6UmmCdfzjryp-2xW09UTCx_qfIpA/edit?usp=sharing
Here you can do it, but can't merge by formula:
= ARRAYFORMULA (
ifna (
vlookup (
ifna (
sort (
{ row(A4:A22) *
len ( vlookup ( A4:A22,
{"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},1,0)
)^0}
,1,true
),""
)
, { row(A4:A22),
left(A4:A22, 1000 *
transpose (
split (join("","1," & rept("0,",countif(A4:A22,unique(A4:A22))-1)),",",true,true))
),
B4:G22
},{2,3,4,5,6,7,8},false
),""
)
)
Another formula with the same result:
= ARRAYFORMULA (
ifna(vlookup (
sort (
{ row(A4:A22) *
len ( vlookup ( A4:A22,
{"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},1,0)
)^0}
,1,true
),
{ row(A4:A22),
if(transpose(split(join(
"","1," & rept("0,",COUNTIF(A4:A22,unique(A4:A22))-1)),",",true,true))=1,
A4:A22,""
),B4:G22
},{2,3,4,5,6,7,8},false),""
)
)
After a little bit of discussion on the sheet, this query() will display only one name per agent, but still list all the rows for that agent.
=ARRAYFORMULA(ARRAY_CONSTRAIN(QUERY({Sheet1!A1:G22,IF(COUNTIFS(Sheet1!A1:A22,Sheet1!A1:A22,ROW(Sheet1!A1:A22),"<="&ROW(Sheet1!A1:A22))>1,"",Sheet1!A1:A22)},"select Col8,Col2,Col3,Col4,Col5,Col6,Col7,Col1 where Col1 matches '"&TEXTJOIN("|",TRUE,A2:A)&"' order by Col1 label Col8'Name'",3),9^99,7))

How to generate a series of repeated data based on its specified quantity in Google Sheets?

I would like to generate a series of repeated data based on its specified quantity in Google Sheets.
For example, in my first sheet, I have the following data:
In the second sheet, I would like it to display a series of data repeated item based on its "Quantity" like this:
Any idea on how to do this?
try:
=ARRAYFORMULA(TRANSPOSE(SPLIT(CONCATENATE(REPT(A:A&"♦", B:B)), "♦")))
or:
=TRANSPOSE(SPLIT(JOIN(",", ARRAYFORMULA(REPT(SPLIT(
INDIRECT("A1:A"&COUNTA(A1:A)), ",")&",",
INDIRECT("B1:B"&COUNTA(B1:B))))), ","))
Assuming your data is in A1
={"Items Repeated";arrayformula(transpose(split(join("☺",rept(A2:A5&"☺",B2:B5)),"☺")))}
Try this:
=transpose
(
arrayformula
(
split
(
join
(
"✪",rept(filter(C33:C,C33:C<>"") & "✪",filter(D33:D,C33:C<>""))
),
"✪"
)
)
)

Resources