Setting header to the Calculation sum - tabulator

I'm using Tabulator 4.9. I set up a table with topCalc:sum.
Now I want to add on a column that has no calculation a text stating "Sum".
I can do that by modifying the cell with the text using Javascript.
Once I edit a field value of o cell in tried to use the cellEdited callback to handle the recalculation. But apparenty the sum is written after this callback to the table and my text disapears.
Is there a way to get hold of the topCalc and add the text afterwards?
User
id
score
Sum
20
user1
1
10
user2
2
10
after editing it looks like
User
id
score
25
user1
1
15
user2
2
10

ok, so if I understand you correctly (without any code examples to go by) you ARE using topCalc:"sum" on your field:"score" column, and want to put the string "Sum" in the topCalc aread of your field:"user" column ?
If so, look at Custom Calculator Functions for your field:"user", just return the string "Sum"

Related

Create a text cell value based on row entries and corresponding columns

I understand this is a tough way of wording the problem I have. Please try and help me.
I want to create a Column called Orders which contains cells based on corresponding item values.
So if I have columns: FlatNo, Truffle, Pineapple, Mango, Chocochips; I want to create a column called Orders which has value:
FlatNo - A51
Mango - 1
Chocochips - 1
(if no values in the Pineapple & Truffle Columns, none show up in Orders columns)
See image
How do I do that ? Thank you in advance
You can use IF and &. & simply puts the different desired things altogether.
Hope the following formula will get you the result for column orders. I have put the number of each item ordered inside parentheses before the item.
="Flat No. "&A2&IF(ISBLANK(B2),"","-("&B2&")"&$B$1)&IF(ISBLANK(C2),"","-("&C2&")"&$C$1)&IF(ISBLANK(D2),"","-("&D2&")"&$D$1)&IF(ISBLANK(E2),"","-("&E2&")"&$E$1)
For instance the third order is shown like this: Flat No. E-23-(1)Truffle -1 Pc Rs 60-(3)Mango -1 Pc Rs 60

Pyspark conditionally replace value in column with value from another column

I am working with some weather data that is missing some values (indicated via value code). For example, if SLP data is missing, it is assigned code 99999. I was able to use a window function to calculate a 7 day average and save it as a new column. A significantly reduced example of a single row is shown below:
SLP_ORIGIN
SLP_ORIGIN_7DAY_AVG
99999
11945.823516044207
I'm trying to write code such that when SLP_ORIGIN has the missing code it gets replaced using the SLP_ORIGIN_7DAY_AVG value. However, most code explains how to replace a column value based on a conditional with a constant value, not the column value. I tried using the following:
train_impute = train.withColumn("SLP_ORIGIN", \
when(train["SLP_ORIGIN"] == 99999, train["SLP_ORIGIN_7DAY_AVG"]).otherwise(train["SLP_ORIGIN"]))
where the dataframe is called train.
When I perform a count on the SLP_ORIGIN column using train.where("SLP_ORIGIN = 99999").count() I get the same count from before I attempted replacing the value in that column. I have already checked and my SLP_ORIGIN_7DAY_AVG does not have any values that match the missing code.
So how do I actually replace the 99999 values in the SLP_ORIGIN column with the associated SLP_ORIGIN_7DAY_AVG value?
EVEN BETTER, is there a way to do this replacement and window calculation without making a 7 day average column (I have other variables I need to do the same thing with so I'm hoping there is a more efficient way to do this).
Make sure to double check with dataframe you are verifying on.
I was using train.where("SLP_ORIGIN = 99999").count() when I should have been using train_impute.where("SLP_ORIGIN = 99999").count()
Additionally, instead of making a whole new column to store the imputed 7 day average, one can only calculate the average when the missing value code is present:
train = train.withColumn("SLP_ORIGIN", when(train["SLP_ORIGIN"] == 99999, f.avg('SLP_ORIGIN').over(w)).otherwise(train["SLP_ORIGIN"]))\

Multi-select fields on Generic Inquiry

How do you filter on multi-select fields on generic inquiry?
Assuming your data looks like this :
ROW VALUES
A 1,5
B 3,4,5
C 5
D 1,2,3
E 2,4
And you want too search for records where there is either 1 or 3. So it should show rows A, B & D. I'm not sure if its possible. So the alternative would be write a custom screen and manipulate via view delegate. I could be wrong though.
TIA
The PXMultiSelector editor control persists the values in string format
How to filter depends on the format. Email address for example have a pre-determined format. For those you can add a standard string filter like Field Contains c#d.com
That wouldn't work for numbers. If you search for number 1 in list 2,4,15 it would return the result because 15 contains 1. To workaround this issue you can add a custom unbound DAC field. In the DAC field property getter you can parse the value of the multi-selector field and reformat it to a pre-determined format like ,2,4,15, and filter on ,1, instead of 1.

EXCEL Look up max number (possible multiple results) and return another column same row

A B
1 Pilot1
3 Pilot2
4 Pilot3
6 Pilot4
15 Pilot5
10 Pilot6
3 Pilot7
8 Pilot8
15 Pilot9
What is the excel formula for looking up the highest value(s) in column A and returning the Pilot(s) name(s).
I am using right now:
=MAX(A1:A9) to return the max number cuz I need that info too.
And
=VLOOKUP(MAX(A1:A9), A1:B9, 2, FALSE)
and this give me the answer if there is on max or the first it comes to for multiple maxes.
So I would get with this:
15
Pilot5
It does not give me
15
15
Pilot5
Pilot9
I want the results to show:
15 - for the max # of flights done
Pilot5
Pilot9 - for the names of the pilots that have the max flight count
So I noted above a more elegant way to do this in Google Sheets. And there are some very obscure ways out there, but here is something simple. The downside is it does show some extra information. Let us say your data is in A1:B9 and in A10 you have =MAX(A1:A9) [this is not strictly needed, but like you said, you want it anyway -- and it makes the formula a little less ugly]
Then in C1 put the formula =if(A1=A$10,B1,"") which will be blank if the pilot is not the max and have the pilot name otherwise. Drag that formula down through C9. Now in C10 (or wherever) put =TEXTJOIN(", ",true,C1:C9)
which will put together your pilot(s) separated by comma and space, and with blank entries omitted.

Return a row number that matches multiple criteria in vbs excel

I need to be able to search my whole table for a row that matches multiple criteria. We use a program that outputs data in the form of a .csv file. It has rows that separate sets of data, each of these headers don't have any columns that are unique in of them self but if i searched the table for multiple values i should be able to pinpoint each header row. I know i can use Application.WorksheetFunction.Match to return a row on a single criteria but i need to search on two three or four criteria.
In pseudo-code it would be something like this:
Return row number were column A = bill & column B = Woods & column C = some other data
We need to work with arrays:
There are 2 kinds of arrays:
numeric {1,0,1,1,1,0,0,1}
boolean {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
to convert between them we can use:
MATCH function
MATCH(1,{1,0,1,1,1,0,0,1},0) -> will result {TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}
simple multiplication
{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE}*{TRUE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE} -> will result {1,0,1,1,1,0,0,1}
you can can check an array in the match function, entering it like in the picture below, be warned that MATCH function WILL TREAT AN ARRAY AS AN "OR" FUNCTION (one match will result in true
ie:
MATCH(1,{1,0,1,1,1,0,0,1},0)=TRUE
, YOU MUST CTR+SHIFT+ENTER !!! FOR IT TO GIVE AN ARRAY BACK!!!
in the example below i show that i want to sum the hours of all the employees except the admin per case
we have 2 options, the long simple way, the complicated fast way:
long simple way
D2=SUMPRODUCT(C2:C9,(A2=A2:A9)*("admin"<>B2:B9)) <<- SUMPRODUCT makes a multiplication
basically A1={2,3,11,3,2,4,5,6}*{0,1,1,0,0,0,0,0} (IT MUST BE A NUMERIC ARRAY TO THE RIGHT IN SUMPRODUCT!!!)
ie: A1=2*0+3*1+11*1+3*0+2*0+4*0+5*0+6*0
this causes a problem because if you drag the cell to autocomplete the rest of the cells, it will edit the lower and higher values of
ie: D9=SUMPRODUCT(C9:C16,(A9=A9:A16)*("admin"<>B9:B16)), which is out of bounds
same as the above if you have a table and want to view the results in a diferent order
the fast complicated way
D3=SUMPRODUCT(INDIRECT("c2:c9"),(A3=INDIRECT("a2:a9"))*("admin"<>INDIRECT("b2:b9")))
it's the same, except that INDIRECT was used on the cells that we want not be modified when autocompleting or table reorderings
be warned that INDIRECT sometimes give VOLATILE ERROR,i recommend not using it on a single cell or using it only once in an array
f* c* i cant post pictures :(
table is:
case emplyee hours totalHoursPerCaseWithoutAdmin
1 admin 2 14
1 him 3 14
1 her 11 14
2 him 3 5
2 her 2 5
3 you 4 10
3 admin 5 10
3 her 6 10
and for the functions to check the arrays, open the insert function button (it looks like and fx) then doubleclick MATCH and then if you enter inside the Lookup_array a value like
A2=A2:A9 for our example it will give {TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE} that is because only the first 3 lines are from case=1
Something like this?
Assuming that you data in in A1:C20
I am looking for "Bill" in A, "Woods" in B and "some other data" in C
Change as applicable
=IF(INDEX(A1:A20,MATCH("Bill",A1:A20,0),1)="Bill",IF(INDEX(B1:B20,MATCH("Woods",B1:B20,0),1)="Woods",IF(INDEX(C1:C20,MATCH("some other data",C1:C20,0),1)="some other data",MATCH("Bill",A1:A20,0),"Not Found")))
SNAPSHOT
I would use this array* formula (for three criteria):
=MATCH(1,((Range1=Criterion1)*(Range2=Criterion2)*(Range3=Criterion3)),0)
*commit with Ctrl+Shift+Enter

Resources