Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
It’ll be auto-updating with that. When a new row gets added it’s part of the column [Date Paid], as everything in that column is (except the header), so it will be included in your formula.

Adbot
ADBOT LOVES YOU

Narzack
Sep 15, 2008
Alrighty, and I apologize for being a total dunce, but I've never really delved into Excel.

So, this formula

=COUNTIF(Table4[Date Paid],”<>”&””)

is saying to count the range and return a value if the cell's contents are not equal to blank, right? I think that's what it is saying. So, when I do that, it returns a zero, which is perfect. But then I tested it and added a a date in one of the cells, the formula still returned a zero. I tried using COUNTA, but when I select the header, and then delete the #ALL, the formula fails. I feel like there is a basic principle here that I am just not latching on to, and, again, I apologize for my denseness.

EDIT: Oh, snap, I left an erroneous comma after Table4. The formula is now =COUNTA(Table4[Date Paid])- which seems to be the same as the COUNTIF that you had. It seems to work, so maybe I should just use that?

Narzack fucked around with this message at 22:59 on Feb 14, 2021

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
Yeah both of those should work, not sure why the former isn’t working. The counta is definitely the easier option because it’s built to do that and the countif using the “<>”&”” is kind of a workaround - it definitely should still get the same answer but there just isn’t an easy way to say notblank: you either user “<>”&”” or maybe the inverse for has a value “*” would get you to the same place as a wildcard for any value.

I don’t have a preferred method, it’s just whatever comes to mind first when I’m entering the formula.

double nine
Aug 8, 2013

how do I auto populate a column depending on a dropdown menu?

For example, if I have a dropdown menu with rock paper scissors, and I want a list with just the people who used that tool how do I do that?

code:
rock		clara
rock 		aaron
paper 		virginie
scissors	liam
scissors	laura
scissors	sam
scissors	jane
so ideally the scenario is: select rock -> only clara and aaron are visible; select scissors ->liam, laura, sam & jane are visible. Obviously the data itself would be hidden elsewhere in the sheet

double nine fucked around with this message at 21:08 on Feb 22, 2021

Zorak of Michigan
Jun 10, 2006


You can't just look at the raw data and use auto filter?

double nine
Aug 8, 2013

I mean I can but I want to learn to be fancy. Also this isn't actually about rock paper scissors stuff obv but a lawyer-friendly alternative :).

Currently I use the "if (drop down cell = "rock", [display stuff], "")" function to keep the cell content invisble when something else is selected. But I was wondering if a more elegant (but NOT filtered) solution existed

double nine fucked around with this message at 00:39 on Feb 23, 2021

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
I don’t think it’s clear what your desired outcome is. Are you just trying to make the results look nice, are you trying to hide the source data or something else?

If you just want to be in “fancy” Excel reporting territory, put it in a pivot table, add a slicer and then take a long lunch before unveiling your masterpiece.

Everett False
Sep 28, 2006

Mopsy, I'm starting to question your medical credentials.

I poked at the idea yesterday because I use a ton of dropdowns and dependent vlookup stuff anyway, but gave up because it turns out that making a second dropdown dependent on the first is actually a huge pain in the rear end and not elegant at all. So, maybe not what you're looking for.

Harminoff
Oct 24, 2005

👽
Looks like this would work

https://excel.officetuts.net/en/formulas/index-match-or-vlookup-to-return-multiple-values

Though yeah seems way easier to just use a pivot table and filter.

Lib and let die
Aug 26, 2004

It's been a while, but I had a workbook with a power query in it that would update based on the value of a specific cell in the workbook (I'd enter a contract number, refresh data, and the query would refresh to the external data source of [contract number from cell].xlsx and display it in a format that was easier for me to copy and paste into the renewal quote). Perhaps something like that would work, where your variable would be the field where your value picker is?

Turkeybone
Dec 9, 2006

:chef: :eng99:
Hi all,

I am trying to create some detail in a pivot table, to ultimately show how a ratio of two options changed between one year and another -- I think the below sums it up well.. I essentially want a "% of Row Subtotal". I have "year" and "option1/option2" as columns.. so basically I want to show what % of the sum was option 1 and what % was option 2 for both years. Any thoughts?




e: if there is some way to build in these percentages in the data itself and sum it up, I am okay with that too.

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
The one you want is the “% of Parent Total...” option, instead of “% of Row Total”. Set that to Year and it should do what you want.

Edit: just right click the current percentages and choose “Show Values As...” to get there.

Hughmoris
Apr 21, 2007
Let's go to the abyss!
Has anyone poked about Office Scripts much? I just found that my O365 subscription for work includes it. Been reading a few articles on it but I haven't really found a use case yet.

mes
Apr 28, 2006

Isn't Office Scripts kinda the web replacement of VBA just using Typescript? I thought it was interesting when I was reading up on it but have yet to actually try anything since my work just migrated to O365 I haven't had a chance.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
I'm writing a report generator that looks things up in a comment bank depending on a value. It currently looks like this

=IF(@Topic1GradeCalc>0,VLOOKUP(RANDBETWEEN(1,5),Topic1CommentBank,2,TRUE),IF(@Topic1GradeCalc=0,VLOOKUP(RANDBETWEEN(6,11),Topic1CommentBank,2,TRUE),VLOOKUP(RANDBETWEEN(12,18),Topic1CommentBank,2,TRUE)))

Is there anyway to make it generate another random number if the thing returned from the lookup is blank or say has NA in? ie if I've not filled that part of the comment bank in?

TheLastManStanding
Jan 14, 2008
Mash Buttons!
- You could use IFNA or ISBLANK to specify a default response for each given lookup.
- INDEX would be better than VLOOKUP since you are just returning an item from a list.
- Avoid using random, it regenerates any time you modify any cell, which lowers performance and will look silly when your comments are constantly switching. Try coming up with some deterministic way you pick which comment is returned.

If you make a table for each class of comments then you could have the code adjust any time you add or subtract comments by using:
INDEX(CommentTable,RANDBETWEEN(1,ROWS(CommentTable)))
or, without the actual random element:
INDEX(CommentTable,MOD(ROW(),ROWS(CommentTable))+1)

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
You could just fill the blanks. Quick way to do that: Select the range, Ctrl+G, Ctrl+B, B, Enter, =, Up arrow, Ctrl+Enter. That selects all the blanks and fills them with the cell value from the above.
Then if you want a visual reminder that you still need to update those ones, add conditional formatting to highlight duplicates to the same range.

And agree with TheLastManStanding on rand and randbetween. Great for generating random values but annoying as poo poo in a working sheet. I was trying to think of a deterministic way where it would just execute once to pull a random value, I could do it in code no problem because you can create a loop but in formulas the closest I can get to a loop is horrible nested IF statements.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
Thanks for the feedback. I've decided there aren't that many blanks so just writing Blank in them is good enough. I have to proofread what it puts together anyway.

Also made the change from vlookup to index which makes sense and should be more reliable.

I understand the concerns with random being inefficient, but can't think of a better way. It's a report generator. It has a variety of intros middles and conclusions and based on some criteria will pick one from each of the appropriate sets and concatenates them together.

TheLastManStanding
Jan 14, 2008
Mash Buttons!
Does it really need to be random though? In the example I posted I was using ROW() to cycle through the choices. If you are picking from 3 different lists then the result should look sufficiently random. If it still looks too much like a pattern then you could built a random number table and use that. Or use the contents of another cell in the row as a random number. There are plenty ways of avoiding using rand.

Carrier
May 12, 2009


420...69...9001...
Say I have a set of data like

SA-TEST 1 | 1,3,4
SA-TEST 2 | 5, 7, 9
SA-TEST 3 | 1, 7, 9, 11

etc.

where there are say SA-TEST 15 is the last and each could contain any number or collection of numbers between 1 and say 11

is there an easy way to convert this table to the form

1 | SA-TEST 1, SA- TEST 3, SA-TEST 12
2 | SA-TEST 7, SA-TEST 9
3 | SA-TEST 1, SA-TEST 4


Where I collect all categories that contain 1, 2, 3 etc.

Ninja.Bob
Mar 31, 2005
I know this is an old question, but here is an answer anyway. You can use something like this (assuming a recent version of excel):

=TEXTJOIN(", ",TRUE,REPT($A$2:$A$16,ISNUMBER(SEARCH(" "&D2&","," "&$B$2:$B$16&","))))

Where
$A$2:$A$16 are the category labels,
$B$2:$B$16 are the number collections, and
D2 is the number you are searching for.

Zaffy
Sep 15, 2003


My boss thinks I'm better at excel than I am and wants to know when users are active during the day. I've told him I'm not that good, and it's cool. This isn't really my job anyway. :)

This data is login and logout times since Jan. So for example, "On average how many people are online at 2pm" (regardless of the day of the week)? I'd like to give him a nice bar graph with each hour and the average # of users who are logged in for those times. Is there an easy way to do this?

nielsm
Jun 1, 2009



Make 24 columns, one for each hour of the day. In each column, calculate a 1 if the time span between login and logout is wholly or partially in that hour of day. You can then sum those columns and make a nice bar chart.

fosborb
Dec 15, 2006



Chronic Good Poster

Zaffy posted:

My boss thinks I'm better at excel than I am and wants to know when users are active during the day. I've told him I'm not that good, and it's cool. This isn't really my job anyway. :)

This data is login and logout times since Jan. So for example, "On average how many people are online at 2pm" (regardless of the day of the week)? I'd like to give him a nice bar graph with each hour and the average # of users who are logged in for those times. Is there an easy way to do this?



if you want max concurrent users for capacity planning, take your login column and paste it into a new worksheet in column A. In column B, fill it entirely with the value 1

Now take the logout column and put it also in column A of your new sheet, but make column B all -1

Sort both columns by column A

In C1, type "max logins." In C2, =SUM(B$2:B2), and then fill the rest of C with that formula such that your last cell is something like =SUM(B$2:B215465) -- you can quickly do this by highlighting the area and pressing Ctrl+D, or double clicking the little box in the bottom right of the cell

copy everything and paste values so you don't gently caress up the formulas

Create a pivot table, group by hour, throw max logins into your values and switch it from Sum to Max

viola!

Zaffy
Sep 15, 2003


nielsm posted:

Make 24 columns, one for each hour of the day. In each column, calculate a 1 if the time span between login and logout is wholly or partially in that hour of day. You can then sum those columns and make a nice bar chart.

Thanks, This clarified what I was kind of trying to do. I made header columns 0 - 23, and this formula seems to work.

=IF(AND(E$1>=HOUR($B2),E$1<=HOUR($C2)),1,0)

fosborb posted:

if you want max concurrent users for capacity planning, take your login column and paste it into a new worksheet in column A. In column B, fill it entirely with the value 1

Now take the logout column and put it also in column A of your new sheet, but make column B all -1

Sort both columns by column A

In C1, type "max logins." In C2, =SUM(B$2:B2), and then fill the rest of C with that formula such that your last cell is something like =SUM(B$2:B215465) -- you can quickly do this by highlighting the area and pressing Ctrl+D, or double clicking the little box in the bottom right of the cell

copy everything and paste values so you don't gently caress up the formulas

Create a pivot table, group by hour, throw max logins into your values and switch it from Sum to Max

viola!

I tried this to see how it looks and I think I'm doing something wrong. The pivot table is grouping by month, and I can't see how to make it go by hours. This is for high school students, we're trying to see when they are logged into their classes.

luckily it's only 45000 rows :)

Harminoff
Oct 24, 2005

👽
Alternatively throw it into power bi and do it in like 3 clicks. Just use the free version and and send a screenshot if you don't have a premium license.

I used to make a bunch of visuals and dashboards in excel, but gently caress thatm power bi is just so much easier at that stuff.

Kibayasu
Mar 28, 2010

So I've started to use pivot tables more and more in my job and I feel like this is something easily answered by Google but I just can't phrase it properly to get the answer (also its probably a really basic function). We were sent another pivot table and data sheet that I'm adapting for our use and the table we received did something I can't quite figure out how to do myself. The Values field has been inserted? into the Columns field so columns of what is in the Values field can be created. See this screenshot:


This seems incredibly simple but I just can't see it :(

DRINK ME
Jul 31, 2006
i cant fix avs like this because idk the bbcode - HTML IS BS MAN
This is how it’s done. I think it’s only possible when you have two or more values in the pivot.

Kibayasu
Mar 28, 2010

DRINK ME posted:

This is how it’s done. I think it’s only possible when you have two or more values in the pivot.

Yeah it is, thanks. Turns out if I had just made two values (which I need!) instead of testing one of them it would have happened automatically. I was wondering why every google result seemed to skip the step of adding values to the columns.

Rakeris
Jul 20, 2014

I don't know poo poo about VB but I hope someone can give me a hand with this.

So I'm trying to populate the current date (into B2) when a new row is added to a table (when something is entered into A2) and then add 15 days to it and put that date in C2 however I want it to also allow me to enter custom dates, and not override it.

Here is my code, I can't seem to get it to work right, probably because it's just random info I have put together from Google, and I don't have any legitimate VB knowledge.

code:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim A As Range, B As Range, Inte As Range, r As Range
    Set A = Range("A2:A2")
    Set Inte = Intersect(A, Target)
    If Inte Is Nothing Then Exit Sub
    Application.EnableEvents = False
        For Each r In Inte
            If r.Offset(0, 1).Value = "" Then
               r.Offset(0, 1).Value = Date
            If r.Offset(0, 2).Value = "" Then
               r.Offset(0, 2).Value = B2 + 15
            End If
        Next r
    Application.EnableEvents = True
End Sub

Ninja.Bob
Mar 31, 2005
You basically had it. The only things that needed changing are your if statements need an end if when they are more than one line and you need to wrap the formula for c2 in double inverted commas, e.g. r.offset(0,2) = "=B2+15"

You say you want this to work for any new row though, so if you change A to be Range("A:A") then when any cell in column A is edited columns b and c will be automatically filled. I have made the column C value generic so it should just work.

code:
Private Sub Worksheet_Change(ByVal Target As Range)    
  Dim A As Range, B As Range, Inte As Range, r As Range    
  Set A = Range("A2:A2")
  Set Inte = Intersect(A, Target)    
  If Inte Is Nothing Then Exit Sub    
  Application.EnableEvents = False    
  For Each r In Inte
    If r.Offset(0, 1).Value = "" Then
      r.Offset(0, 1).Value = Date
    End If
    If r.Offset(0, 2).Value = "" Then
      r.Offset(0, 2).Value = "=" & r.Offset(0, 1).Address(False, False) & "+15"
    End If
  Next r    
  Application.EnableEvents = True    
End Sub

Rakeris
Jul 20, 2014

Ah, awesome, thank you!

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
In case anyone cares about something like... I was looking how to serve compact (i.e. not repeating column names every record) tabular JSON from my web services and decode it with PowerQuery in Excel, so here's a tiny M script template that does it (since you can't seem to solely click yourself through the UI to unfold that):

code:
let
    source = Json.Document(File.Contents("C:\Temp\test.json")),
    cols = Table.Transpose(Table.FromList(source[columns], Splitter.SplitByNothing(), null, null, ExtraValues.Error)),
    data = Table.FromRows(source[results]),
    output = Table.PromoteHeaders(Table.Combine({cols, data}), [PromoteAllScalars=true])
in
    output
To decode stuff in this format:

code:
{
    "columns": ["col1", "col2", "col3"],
    "results": [
      ["Foo", "Bar", "Wee"],
      ["Abc", "Def", "Ghi"],
      ["Xxx", "Yyy", "Zzz"]
    ]
}
Also, certainly not a fan of any Google searches regarding PowerQuery typically returning guides focusing on doing things via the UI only instead of scripting.

Kibayasu
Mar 28, 2010

Is there an easy or simple way to choose which external data is displayed in a worksheet? Like choose a name from a drop down list and display a table or maybe even several tables I’ve somehow linked to that name? Or am I looking at diving into VBA or something else with that?

Combat Pretzel
Jun 23, 2004

No, seriously... what kurds?!
Depends on how you want to go about it. Downloading the data on demand, you'd need to mess around with M code in Power Query, too, to extract a value from the sheet and concat it with the query text. Or you could load all data into Excel and play around with XLOOKUP.

Kibayasu
Mar 28, 2010

I was mostly hoping against hope that there was some incredibly simple way I didn’t know about to code something like “If cell X = Y then display Table A in cell Z.”

I don’t believe a lookup will work for what I need because the name will be associated with a worksheet instead of a single column or row and may need to display multiple cells of different kinds data. So if someone selects Depot A it will display things like Open time, Close time, after hours access, restrictions on space, restrictions on service time, and so on.

I’m thinking I’m stuck with INDIRECT as time consuming as that can be but that might just be because it’s the only answer I know.

AzureSkys
Apr 27, 2003

I'm struggling to pair the right things to do a lookup in a schedule workbook to find a specific date in a master workbook. The master workbook lists all the product numbers in column A, like 111, 112, 113, etc. Column B for each product number has a stage in production, like "received", "day 1", "day 3", "finish", etc., up to about 11 stages. Then each stage has its scheduled date of completion next to it in column C.

I then need my schedule workbook to lookup the date for a product number's stage, like "day 4". It's a list of all the product numbers in one column and then a specific stage's date next to it.

code:
Master.xlsx
A	B		C
111	Rec 	01/01/21
111	Start	01/02/21
111	Day1	01/03/21
111	Day2	01/04/21
111	Day3	01/05/21
111	Day4	01/08/21
111	Fin	01/09/21
111	Ship	01/11/21
112	Rec	01/05/21
112	Start	01/06/21
112	Day1	01/07/21
112	Day2	01/08/21
112	Day3	01/09/21
112	Day4	01/10/21
112	Fin	01/13/21
112	Ship	01/15/21
I then want my other sheet to list Day4's date next to the product number. Column A is put in manually as needed, but then C need to be lookup of some kind based on what's in B:
code:
StageSchedule.xlsx
A	B	  C
111	Day4 01/08/21
112	Day4 01/10/21
113	Day4 01/15/21
114 	Day4 01/19/21
I can't quite figure out how to have it lookup the product number of the schedule sheet and then match the correct stage column and date. I did find a way that would work using OFFSET and some stuff, but then that doesn't work if the other workbook is closed. I'm trying to simplify it for non-excel savvy people to use by just grabbing an updated copy of the master file, putting it in a folder, then having the schedule workbook find the info for them.

TheLastManStanding
Jan 14, 2008
Mash Buttons!
Data Tab > New Query > From File > From Workbook
Pull in your master data table.
Filter the column for Day4.

This would give you all of the product/dates for Day4.
They could then filter this down to the products they want.

If you really want a table where they plug in combinations and it gives a result then:
For table 1 (your master table) add a column AB that is
=[@A]&[@B]
Then for column C in table 2 (your new table) use
=INDEX(Table1[C],MATCH([@A]&[@B],Table1[AB],0))

Boba Pearl
Dec 27, 2019

by Athanatos
Cross posting, but I don't know if google sheets is comparable to excel, or if this would even be something possible in either.

Boba Pearl posted:

Is this a thing I can do in google sheets? (Or if someone could help me recreate the script in excel, could I do this in excel.)

So in this sheet: https://docs.google.com/spreadsheets/d/16wCsVT_2NLWEZGCS3erdFFL9lDieQ6xxZYCE88fFI5E/edit?usp=sharing

I have a bunch of encounters copy pasted from the compendium in DND 4e, to cells in google sheets, I then have a script to the far right, that looks for certain keywords in the script and changes it to roll code for roll 20. It does this dynamically, and while there are some bugs with it, it works for what I need.

This is the script: https://pastebin.com/tFiAxbNw

What I'd like to add as a functionality, is either by whether or not a cell is bold, or maybe by color, or some other appropriate signifier get it to add "/me " before the move names. This would make the text before the attack appear bright orange, as my players sometimes loses attacks because of the way roll20 will concatenate a set of rolls made together. What is a good way to get this sheet to do that, either with inline code, or maybe a google script, or an excel script, if someone can teach me how to recreate the google sheets find replace script in excel.

Adbot
ADBOT LOVES YOU

Rakeris
Jul 20, 2014

I feel like I am overlooking a simple way to do this, but I want to create a command button/form button, to copy wtvr is in column Q and put it in column P, but I only want it to do it for certain words (either by whitelisting or blacklisting or wtvr)

Can I make a blacklist or whitelist using vba?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply