excel pivot table sorting - excel-2010

How pivot table sorts data in row label and column label
It resulted quite strange to me.
as source sheet has a column with data in format "year month week" (e.g 2012 10 wk 4) as text data
when using this column as row label and column label in pivot it resulted as
2012 08 wk 4
2012 09 wk 1
2012 09 wk 4
2012 09 wk 3
2012 09 wk 2
source sheet has data in correct order 2012 09 wk 1, wk 2, wk 3, wk 4... but when using it in pivot table disturbs the order which should be as in source sheet

You might need to right-click on the say the first row where a value you wish to sort appears (eg where it says '2012 08 wk 4') and choose the sort menu option from the right-click menu.
In the image below, I right-clicked on the value 896,321......

Related

How to use Google Query to combine multiple rows into a single row with IF & SUM

We can get the following raw data from our project management software:
Month
Project
Billable
Time
Jan 2022
Project 1
Yes
100
Jan 2022
Project 1
No
10
Feb 2022
Project 1
Yes
80
Feb 2022
Project 1
No
30
Jan 2022
Project 2
Yes
60
Jan 2022
Project 2
No
5
Feb 2022
Project 2
Yes
90
Feb 2022
Project 2
No
15
I need to change this data to the following format:
Month
Project
Billable Time
Non-Billable Time
Total Time
Jan 2022
Project 1
100
10
110
Feb 2022
Project 1
80
30
110
Jan 2022
Project 2
60
5
65
Feb 2022
Project 2
90
15
105
Putting the raw data into a Google Sheet I thought this might be possible using Google Query. I started with this:
=QUERY(dataRange,"SELECT Month,Project,SUM(Time) GROUP BY Month, Project")
But I can't work out how to separate Billable & Non-Billable time & include this on a single row with the SUM of both times. Is this even possible using =QUERY?
If =QUERY can be used, what syntax should I use?
If =QUERY can't be used, what method should I use instead?
Use the QUERY pivot clause like this (assuming your source table is in A1:D9 of your sheet):
=query(query({A1:D9},"select Col1,Col2,sum(Col4) group by Col1,Col2 pivot Col3 order by Col2",1),"select Col1,Col2,Col4,Col3,Col3+Col4 label Col3 'Billable time',Col4 'Non-billable time',Col3+Col4 'Total time'",1)
You can also try:
={{A1:B1,C1&" "&D1,"Non- "&C1&" "&D1,"Total "&D1};INDEX(BYROW(UNIQUE(FILTER(A2:A&"|"&B2:B,A2:A<>"")),LAMBDA(ax,{SPLIT(ax,"|",0,0),SUMIFS(D:D,C:C,"Yes",A:A&"|"&B:B,ax),SUMIFS(D:D,C:C,"No",A:A&"|"&B:B,ax),SUMIFS(D:D,A:A&"|"&B:B,ax)})))}

Google Sheets - transpose irregular column data in groups into rows

Much like the problem with the transposing of data in transpose column data I am stuck trying to transpose a set of data with multiple variables. The biggest issue I face is trying to remove useless data. Table 1 is how the data is received
Column N
Sep 07 2022
Alert
Something went wrong
fish company
70000123456
1234567
231.03
View Details
Sep 07 2022
---
meat company
70000987654
688773
View Details
Sep 07 2022
Success
produce company
70000192837
View Details
Table 2 is the desired output
Column A
Column B
Column C
Column D
Column E
date
vendor
po
Invoice
cost
Sep 07 2022
fish company
70000123456
1234567
231.03
Sep 08 2022
meat company
70000987654
D688773B
Sep 07 2022
produce company
70000192837
I was unable to trim cells Alert and Something went wrong due to nesting errors.
REDUCE the array to the string, joined by delimiters. If the value is a date, join by 🍚, else if it's a value of interest determined by REGEXMATCH, join by πŸ‡. From the created string, split by the row delimiter 🍚, TRANSPOSE and SPLIT by the column delimiter πŸ‡
=ARRAYFORMULA(SPLIT(TRANSPOSE(SPLIT(REDUCE(,A2:A20,LAMBDA(a,c,IFS(ISDATE(c),a&"🍚"&TO_TEXT(c),REGEXMATCH(TO_TEXT(c),".*company|70{5}\d+|\d+"),a&"πŸ‡"&c,TRUE,a))),"🍚")),"πŸ‡"))
Sep 07 2022
fish company
70000123456
1234567
231.03
Sep 07 2022
meat company
70000987654
688773
Sep 07 2022
produce company
70000192837
If you don't care about dragging formulas, you might be able to use something like the following steps I did:
Pasted your data starting in cell A2.
Put a formula for to identify dates to the right of your data starting in cell B2: =N(B1)+if(ISDATE(A2),1,0) (NOTE this formula isn't dynamic)
Create a unique list filter list cell D1: =UNIQUE(Filter(B:B,B:B<>""))
Used formula to parse out data next to unique list (so starting in E2): =Transpose(FILTER(if(A:A="Alert",,A:A),(B:B=D2)*(A:A<>"ALert")*(A:A<>"Something Went Wrong")*(A:A<>"View Details")))
As you can see in part 4, I tried to strip out members that you flagged as irrelevant. I'm not sure what other rules you have.
There's probably a way to make steps 2 and 4 dynamic spill formulas, but that's all I have time for.
Ended up with this (yellow cells have relevant formula).

How tranpose the data of more than 1 cell to only 1 cell on google sheets?

I have the following column :
A1
Miu Kei Yuk
3354
of
2018
8 April 2022
and need to separate it into 3 columns :
3354 of 2018 Miu Kei Yuk 8 April 2022
So the first and the fifth row are correct, but the row number 2, 3 and 4 needs to be in only 1 cell.
I tried transpose(A1:A5) but iu results in :
Miu Kei Yuk domingo, março 07, 1909 of 2018 8 April 2022
Is it possible to do it ?
try:
={A2&" "&A3&" "&A4, A1, A5}
or:
={A2&" "&A3&" "&A4\ A1\ A5}
For Portuguese Locale use this formula or Make a copy of this example.
={TEXTJOIN(" ";1;A2:A4)\
A1\
A5}
For United States locale use this formula
={TEXTJOIN(" ",1,A2:A4),
A1,
A5}

Google sheets formula to sumif within other sheets in the workbook, without writing out the sheet name, instead using reference/contents column?

I have a googlesheet (sheet 1) which looks like this:
contents contains a column with Months
May 2021
June 2021
July 2021
August 2021
September 2021
October 2021
November 2021
December 2021
January 2022
February 2022
March 2022
April 2022
May 2022
June 2022
Each month / cell in column A (sheet 1) all link to another sheet within the workbook containing the data for each month, all data has different rows, so to summarise each month, I want a formula like this:
=sumif(indirect(A4,&"!A:A"),"ProductA",(indirect(A&"!B:B")))
where A4 references January 2021, and this is linked to sheet January 2021, ProductA is in column A of each monthly breakdown (all sheets after sheet 1), and the number of these in column B.
I want to be able to drag this formula down, and have the sheet look for the sum of ProductA across all months, using Column A in sheet 1 to reference the sheet it should look in, i.e. the month.
Does this make any sense?
I can add more info, apologies for the waffle.
Sheet 2 for example contains Month1 data and looks like this:
Category (Ticket) Count Thread Time
prod1 5 22 8395:35:00
prod2 67 5411 644:24:00
prod3 544 55 18283:24:00
prod4 56 546546 97093:52:00
prod5 75 646 38238:11:00
Here is a formula that should work for you:
=arrayformula(sumif(indirect($A2&"!A:A"),C$1,(indirect($A2&"!B:B"))))
You can place this into cell C2, and then copy it down and across.
The issue with your formula was first that you had (indirect(A&"!B:B")), instead of (indirect(A2&"!B:B")).
Secondly, you need to make sure that there's no extra space after your values.
In the above image, you have an extra space after prod3, so when using the SUMIF and trying to match the value, it was not working. If something is resulting in 0 where it shouldn't be, make sure to check that first. I have found that prod4 and prod6 both have the same issue.

Transpose and repeat column

I know this might be a long shot but here it goes:
Let's assume I have this data:
A B
2014 1
2015 2
2016 3
2017 4
2018
Those columns are not related. But based on that I would like to create a table like this:
2014 2014 2014 2014 2015 2015 2015 2015 2016 2016 2016 2016
1 2 3 4 1 2 3 4 1 2 3 4
Or even better have each column repeated 5 times. What I want to achieve i that I will have data for each year and quarter, and then I would like to display each quarter separately and at the end of each year to have an average:
2014 2014 2014 2014 2014 2015 2015 2015 2015 2015 2016 2016 2016 2016 2016
1 2 3 4 avg 1 2 3 4 avg 1 2 3 4 avg
I've used TRANSPOSE(A2:B6) but I'm stuck on the repetition side of things, if it's even possible
Since I have data in a first column, perhaps something like this is easier to achieve:
A B C D
2014 2015
Label A 1 x x
Label A 2 x x
Label A 3
Label A 4
Label B 1
The labels in A column are taken using QUERY, just a list of, for example, people - can I repeat them? The Xs would then be a singular query to get right data for column A,B, and C
There is rept for repeating a string a given number of times. It can be abused for other data by way of join and split, if you can pick a suitable delimiter (some character that isn't going to be present in the data). I use | as a delimiter:
=split(join("", arrayformula(rept(A2:A6 & "|", 5))), "|")
This puts the content of A2:A6 in a row, repeating each entry 5 times.
Similar trick to have the content of B2:B6 repeated but in a loop: 1, 2, 3, 4, avg, 1, 2, 3, 4, avg ... :
=split(rept(join("|", B2:B6), 7), "|")
Here 7 is the number of times the loop should be repeated.

Resources