How to add 2 Attributes one after another in MSTR? - microstrategy

I am new to MSTR and trying to build a new Dossier and i got stuck on the below issue.
I have 2 attributes and 1 metric in my dataset and Attribute 1 has data A, B & C and Attribute 2 has data X, Y, Z. i want dashboard to look like this
Attribute Metric
A 1
B 2
C 3
X 4
Y 5
Z 6
When i create my result look like below.
Attribute1 Attribute2 Metric
A X 1
B y 2
C z 3
Please help.

Can you reformat your results - Attribute Metric A 1 B 2 C 3 X 4 Y 5 Z 6
I think you mean you want to view metrics for the elements for both the attributes appended one below the other.
I'd suggest you create a consolidation / custom group object and add all elements from both your attributes.
And use this consolidation / custom group instead of the attribute on your report.

Related

How to pick the highest value in each category in Tableau

I have to pick the highest value from col 2 in relation col 1 using Tableau. The data is as follows
col 1 col 2
category 1 5
category 2 6
category 1 4
category 1 3
category 2 10
category 1 1
category 2 3
The desired solution is
col 1 col 2
category 1 5
category 2 10
I tried using the fixed aong with max function but in this case it outputs boolean value which I do not need. Could someone help me!
Thank you
Drag col 1 in the rows shelf.
Double click col 2.
Right-Click col 2 --> measure --> Maximum
(Eventually) Drag Max(col 2) from row shel to Text Mark
EDIT
See the screenshot as an example.
[To be noted that you can achieve this simple result with differnt ways/clicks]
BTW: are you familiar with dimensions and measures? it seems to me that you may need some basics training/study in order to get familiar with Tableau basics.
You may start from here: https://www.tableau.com/en-gb/learn/training/20212

generate serial number in decreasing order given a variable in tableau

would like to find out the syntax in tableau, given column number, trying to generate rows for number in decreasing order down to 0.
Below is an example of what I'm trying to do
BEFORE
ID
NUMBER
A
4
B
5
AFTER
ID
NUMBER
A
4
A
3
A
2
A
1
B
5
B
4
B
3
B
2
B
1
If your Tableau version supports, try using ROWNUMBER with order by. Something like this:
{ ORDERBY [Your column]:ROW_NUMBER()}

Calculating group means with own group excluded in MATLAB

To be generic the issue is: I need to create group means that exclude own group observations before calculating the mean.
As an example: let's say I have firms, products and product characteristics. Each firm (f=1,...,F) produces several products (i=1,...,I). I would like to create a group mean for a certain characteristic of the product i of firm f, using all products of all firms, excluding firm f product observations.
So I could have a dataset like this:
firm prod width
1 1 30
1 2 10
1 3 20
2 1 25
2 2 15
2 4 40
3 2 10
3 4 35
To reproduce the table:
firm=[1,1,1,2,2,2,3,3]
prod=[1,2,3,1,2,4,2,4]
hp=[30,10,20,25,15,40,10,35]
x=[firm' prod' hp']
Then I want to estimate a mean which will use values of all products of all other firms, that is excluding all firm 1 products. In this case, my grouping is at the firm level. (This mean is to be used as an instrumental variable for the width of all products in firm 1.)
So, the mean that I should find is: (25+15+40+10+35)/5=25
Then repeat the process for other firms.
firm prod width mean_desired
1 1 30 25
1 2 10 25
1 3 20 25
2 1 25
2 2 15
2 4 40
3 2 10
3 4 35
I guess my biggest difficulty is to exclude the own firm values.
This question is related to this page here: Calculating group mean/medians in MATLAB where group ID is in a separate column. But here, we do not exclude the own group.
p.s.: just out of curiosity if anyone works in economics, I am actually trying to construct Hausman or BLP instruments.
Here's a way that avoids loops, but may be memory-expensive. Let x denote your three-column data matrix.
m = bsxfun(#ne, x(:,1).', unique(x(:,1))); % or m = ~sparse(x(:,1), 1:size(x,1), true);
result = m*x(:,3);
result = result./sum(m,2);
This creates a zero-one matrix m such that each row of m multiplied by the width column of x (second line of code) gives the sum of other groups. m is built by comparing each entry in the firm column of x with the unique values of that column (first line). Then, dividing by the respective count of other groups (third line) gives the desired result.
If you need the results repeated as per the original firm column, use result(x(:,1))

How to group a column in tableau based on value of another column

I am new to tableau and need help in figuring this out.I have a dataset in below format:
hid:id for the house the customer belong
cid:customer id
hID CustomerID
1 A
1 B
1 C
2 D
2 E
3 F
3 G
3 H
3 I
4 J
5 K
5 L
5 M
5 N
5 O
So A,B belong to house 1 so count of hid '1' is 3 so:
hid count of members
1 3
2 2
3 3
4 1
5 5
I want to show a graph in tableau as size of house that is X-axis :Size of house and Y-axis :Count no of house with same size so for above data the values as below:
Size of house no of house
1 1
2 1
3 2
4 0
5 1
The final graph should be:
In Tableau jargon, you're looking to bin based upon an aggregate value. Take a look at the following blog post for a more detailed description/walk-through.
One way to accomplish this is by leveraging talbeau's level of detail calculations. Creating a calculated field along the lines of:
{FIXED [hID] : COUNTD([CustomerID])}
You can then create a bin field by right clicking on the new field and binning based on a parameter, or a a static size (1?) of your choosing.
To create the visual, place this second bin field on the row shelf and on the column shelf drag the hID dimension and right click to convert to a measure by selecting Count Distinct.
As a side note, depending on whether you set your bin field as continuous or discrete, the 4 bin in your sample data will or will not appear.

Aggregating from multiple columns in Tableau

I have a table that looks like:
id aff1 aff2 aff3 value
1 a x b 5
2 b c x 4
3 a b g 1
I would like to aggregate the aff columns to calculate the sum of "value" for each aff. For example, the above gives:
aff sum
a 6
b 10
c 4
g 1
x 9
Ideally, I'd like to do this directly in tableau without remaking the table by unfolding it along all the aff columns.
You can use Tableau’s inbuilt pivot method as below, without reshaping in source .
CTRL Select all 3 dimensions you want to merge , and click on pivot .
You will get your new reshaped data as below, delete other columns :
Finally build your view.
I hope this answers . Rest other options for the above results include JOIN at DB level, or creating multiple calculated fields for each attribute value which are not scalable.