Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Can I sort by one column and if its empty use a different column?

$
0
0

I have a google sheet with 5 Tabs, 1 being the master calendar and 2-5 being individual class calendars.

They each look like this:

ClassTypeNameDate OpenTime OpenDate DueTime Due
TMAReadingIntroductionJan 911:59 PM
TMAReadingCh.1Jan 1211:59 PM
TMAEssayEssay 1Jan 108:00 AMJan 1111:59 PM
TMAEssayEssay 2Jan 148:00 AMJan 1511:59 PM
TMAExamMidtermJan 129:00 AMJan 1311:59 PM

How would I make the master document sort all classes by Date Open, then Time Open, then Date Due, then Time Due, with ones that have no Time Due in the front, but if Date Open is blank, then sort by Date Due, then Time Due, with ones that have no Time Due in the front. I'll provide and If else statement:

If Date Open != empty (sort by Date Open, then Time Open, then Date Due, then Time Due, and if there's no Time Due, put at front of that Day)

Else (sort by Date Due, then Time Due, and if there's no Time Due, put at front of that Day)

I would want the Master Calendar to look Like

ClassTypeNameDate OpenTime OpenDate DueTime Due
TMAReadingIntroductionJan 911:59 PM
WRTGExamSyllabus ExamJan 108:00 AMJan 114:00 PM
TMAEssayEssay 1Jan 108:00 AMJan 1111:59 PM
TMAExamMidtermJan 129:00 AMJan 1311:59 PM
SOCClassNo ClassJan 12
WRTGReadingOP EDJan 124:00 PM
TMAReadingCh.1Jan 1211:59 PM
TMAEssayEssay 2Jan 148:00 AMJan 1511:59 PM

I have tried the built-in Sort and Range buttons at the top, but they don't allow for conditional sorting.

I have no idea what I'm doing when it comes to the scripting part of it, I think that's what its called, but what I have tried is.

EDIT:I've gotten

=SORT({'REL C 200'!A2:G49;'TMA 140'!A2:G32;'TMA 367'!A2:G151;'SOC 111'!A2:G64}, IFNA(4, 6), TRUE)

=SORT({'REL C 200'!A2:G49;'TMA 140'!A2:G32;'TMA 367'!A2:G151;'SOC 111'!A2:G64}, IF(ISBLANK(D), 6, 4), TRUE, IF(ISBLANK(D), 7, 5), TRUE)

Which both sort everything that has Date Open by its Date Open, but the rest are just shoved in in order of which tab came first.

I also tried

=SORT({'REL C 200'!A2:G49;'TMA 140'!A2:G32;'TMA 367'!A2:G151;'SOC 111'!A2:G64}, IF(ISBLANK(D2), 6, 4), TRUE)

Which sometimes kinda works? It either throws a "circular dependency detected" or it sorts by the Date Due

Then I tried

=SORT({'REL C 200'!A2:G49;'TMA 140'!A2:G32;'TMA 367'!A2:G151;'SOC 111'!A2:G64}, SWITCH(D2:D293, NOT(ISBLANK(D$2)), 4, ISBLANK(D$2), 6), TRUE)

It said there was a circular dependency detected, and I'm not sure if it could work at all or if SWITCH is just not the right function.

Here is a Link to the Spreadsheethttps://docs.google.com/spreadsheets/d/1SdlgcIzFkk2mAnAm7ilhYmDtjWEeZrJy8p6NBfXNRx8/edit?usp=sharing


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>