Get name of column with highest value in a row [closed] - openoffice-calc

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I need a formula to get the name of the column with the highest value in each openoffice (libreoffice) calc row, ie:
A0 | A1 | A2 | A3
------------------------------------
field1 | field2 | field3 | heighest*
------------------------------------
10 | 12 | 8 | field2*
------------------------------------
7 | 5 | 15 | field3*
------------------------------------
etc...
Thank you

I don't have openoffice installed to check against it, but this seems to work in a google spreadsheet:
=Indirect(Address(1, Match(Max(A2:C2),A2:C2, 0)))
google spreadsheet

Related

PowerBI generate table from another table

Good morning,
I have the following table with RAW data:
USER | YEAR | I1 | G1 | I2 | G2 | I3 | G3
A | 2021 | 1 | 3 | 4 | 2 | 5 | 1
B | 2021 | 3 | 2 | 1 | 2 | 4 | 1
And I need to create from this table another table, generating 3 new lines per Table A line.
USER | YEAR | # | I | G
A | 2021 | 1 | 1 | 3
A | 2021 | 2 | 4 | 2
A | 2021 | 3 | 5 | 1
B | 2021 | 1 | 3 | 2
B | 2021 | 2 | 1 | 2
B | 2021 | 3 | 4 | 1
I cannot find how to do it in PowerBI. I worked with other languages in which I would face this by extracting 3 times the information from the first table (in the first extraction I would select the I1 and G1, in the second one the I2 and G2 and in the third one the I3 and G3) and I would append it. However, I am not able to find in google how to do this with DAX.
Can anyone help me?
Thank you so much,
I believe you are asking how to do this with DAX simply because this is the only way you've heard. In Power BI, you should do such transformation using M, i.e. in Power Query Editor.
The format of the data is not optimal, so you will need to transform it a bit more. So open Power Query Editor by clicking on Transform data button in the ribbon, and then make a copy of your table by right-clicking it in the list and select Duplicate. Delete I1, I2 and I3 columns from one of the tables, and delete G1, G2 and G3 columns from the other. In each of the tables, select all three Ix/Gx columns and click Transform -> Unpivot Columns. After this step, the tables should looks like this:
Rename Values columns to I and G, and in each of the tables split the Attribute column by right clicking the column title and selecting Split column -> By number of characters... like this:
Rename the column with the numeric value (Attribute.2) to # in both tables and remove the other one (Attribute.1). After this stage, you should have two tables with the first 3 columns the same, and I and G columns containing the numeric values:
Now you must merge these two tables together, by clicking the drop down of Home -> Merge Queries and selecting Merge Queries as New, then select your two tables and select USER, YEAR and # columns as keys in both lists:
Expand the table by clicking the button in the columns title:
And leave only the other value, so at the end (after renaming the columns) you will get the desired result:

Correcting constraint mlogit stata [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
So I'm in a bit of a trouble. I need to put constraint on my data in state to run a mlogit, but it keeps stating that the equation have not been found. Can someone help?
It is hard to determine exactly what is going wrong since you don't provide complete output or an MCVE. Error 303 means:
You referred to a coefficient or stored result corresponding to an
equation or outcome that cannot be found.
This means you probably are defining the constraint incorrectly by referring to the numeric values rather than the corresponding value label that Stata used to label each equation.
Instead of
constraint 1 [insure=3]:age =-1*[insure=2]:age
try something like this:
. webuse sysdsn1
(Health insurance data)
. label list insure
insure:
1 Indemnity
2 Prepaid
3 Uninsure
. constraint 1 [Uninsure]:age =-1*[Prepaid]:age
. mlogit insure age male i.site, constraints(1) nolog
Multinomial logistic regression Number of obs = 615
Wald chi2(7) = 20.43
Log likelihood = -544.32915 Prob > chi2 = 0.0047
( 1) [Prepaid]age + [Uninsure]age = 0
------------------------------------------------------------------------------
insure | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Indemnity | (base outcome)
-------------+----------------------------------------------------------------
Prepaid |
age | -.0054932 .0046759 -1.17 0.240 -.0146579 .0036714
male | .4673414 .1980637 2.36 0.018 .0791436 .8555392
|
site |
2 | -.0030463 .2045162 -0.01 0.988 -.4038907 .397798
3 | -.4001761 .2179144 -1.84 0.066 -.8272804 .0269282
|
_cons | .1940359 .2672973 0.73 0.468 -.3298572 .717929
-------------+----------------------------------------------------------------
Uninsure |
age | .0054932 .0046759 1.17 0.240 -.0036714 .0146579
male | .4015065 .3642457 1.10 0.270 -.3124019 1.115415
|
site |
2 | -1.192478 .4670081 -2.55 0.011 -2.107797 -.2771591
3 | -.1393011 .3592712 -0.39 0.698 -.8434596 .5648575
|
_cons | -1.868834 .3596923 -5.20 0.000 -2.573818 -1.16385
------------------------------------------------------------------------------

PowerBI Sort Columns in Matrix Visual

I have a Matrix visual in Microsoft PowerBI with Australian 'States' as rows and 'Months Ago' as columns.
By default the Matrix shows my columns from 0 months ago to 12. I would like it to show from 12 months ago on the left to 0 months ago on the right.
+-------------------+-----------------------------+-------+
| | Months Ago | |
+-------------------+-----------------------------+-------+
| State | 0 | 1 | 2 | 3 | 4 | 5 | Total |
+-------------------+----+----+----+----+----+----+-------+
| Queensland | 10 | 10 | 10 | 10 | 10 | 10 | 60 |
+-------------------+----+----+----+----+----+----+-------+
| New South Wales | | | | | | | |
+-------------------+----+----+----+----+----+----+-------+
| Victoria | | | | | | | |
+-------------------+----+----+----+----+----+----+-------+
| South Australia | | | | | | | |
+-------------------+----+----+----+----+----+----+-------+
| Western Australia | | | | | | | |
+-------------------+----+----+----+----+----+----+-------+
Currently I am only given the option to sort by the value type fields (ie revenue etc).
Is there any option to sort/order the Column Headers?
I don't think there is an option for you to sort column headers directly.
However, you can change the default sort order for the Months Ago column so that it will be reflected in general.
You can add a custom column MonthSrt = 12 - [Months Ago] in query editor:
(It won't work in DAX because of a known issue)
Then you can select the Months Ago column and sort it by MonthSrt:
The custom sort will be applied when you use the Months Ago column in visuals:
You can also make groups (1 to 1 items) al give them al logical number:
The order will change automaticly in the matrix
The following solution worked for me to display the dates in descending order in a matrix:
how to sort column dates in descending order of matrix in power bi

How to delete variables which occur in column x but not in column y?

How can I delete duplicates which occur in column x but not in column y?
My dataset is as follows:
+-------+---+---+
| year | x | y |
+-------+---+---+
| 2001 | 1 | 2 |
| 2001 | 2 | 3 |
| 2001 | 2 | 3 |
| 2001 | 4 | 6 |
| 2001 | 5 | 9 |
| 2001 | 4 | 2 |
| 2001 | 4 | 9 |
+-------+---+---+
What I want is to remove the entries which occur in column y from the ones in column x.
My result would be: 1,4,5
I am currently learning Stata and I would love to know a good source for all possible commands, if this exists? So I can learn better on my own. Currently I have trouble to find good sources.
In Stata what you call columns are always called variables.
See http://www.statalist.org/forums/help#stata for general advice on how to present data examples in Stata questions. (The comments on CODE delimiters don't apply here.)
This may help. I didn't understand the role of year in your problem.
clear
input year x y
2001 1 2
2001 2 3
2001 2 3
2001 4 6
2001 5 9
2001 4 2
2001 4 9
end
rename x Datax
rename y Datay
gen long obs = _n
reshape long Data, i(obs) j(which) string
bysort Data (which) : drop if which[_N] == "y"
list
+---------------------------+
| obs which year Data |
|---------------------------|
1. | 1 x 2001 1 |
2. | 4 x 2001 4 |
3. | 7 x 2001 4 |
4. | 6 x 2001 4 |
5. | 5 x 2001 5 |
+---------------------------+
All possible commands aren't documented in a single place. Someone could write new commands all the time and they would not be documented anywhere except their help files. Did you mean that? Nor are all existing commands documented in one place: many are user-written and most of those are just documented by their help files.
Most of the official commands in Stata as supplied by StataCorp are documented in the manuals. Literally, there are also undocumented commands (I am not inventing this: see help undocumented) and there are also nondocumented commands that exist, known about because StataCorp mention them in talks or emails. To be as positive as possible: start with the manuals, bundled with your copy of Stata as .pdf files.

How can I match two columns of data by name?

I have two sets of data that look something like this:
Bill | 7
Sam | 13
Chuck | 9
and
Bill | 6
Sam | 3
Beth | 6
and I want:
Beth | 0 | 6
Bill | 7 | 6
Chuck| 9 | 0
Sam | 13 | 3
I don't even care if the data ends up looking like this:
Bill | 7 | Bill | 6
| | Beth | 6
Sam | 13 | Sam | 3
Chuck| 9 | Chuck| 0
I just would like to match up the names.
Your desired outcome - I've never seen such an order in "real life practice".
To use the data, I would go with an operating system tool to combine the source files
(like: copy file1 + file2 newfile.csv; new file extension for easily recognizing by OOo Calc).
In CALC you can then sort / filter, to show a persons data together, or sum / calculate with it.
If you want standard operations, like SUM per person, check out the pivot table feature.
HTH