I am trying to push my data in Tableau by one cell. My current data is in the format below:
Month | Actual
--------------
1 | 0
2 | x
3 | y
4 | z
I want to create a calculated field that will push the data in actual by one cell based on a condition such that I have a new field as expected below:
Month | Actual | Expected
-------------------------
1 | 0 | 0
2 | x | 0
3 | y | x
4 | z | y
It will be helpful if anybody can tell me a correct way of updating the value.
You can do this using a table calculation, but it is important how you show the data in your view.
Create a new calculated field and use the following logic:
IFNULL(LOOKUP(MAX([Actual]),-1),'0')
Your view and output should look like this:
Related
I have a pySpark dataframe and need to compute a column which depends on the value of the same column in the previous row. But instead of using the old value of this column of the previous row, I need the new one, to which the calculation was already applied.
Specifically, I need to compute the following: Given a dataframe with a column A in a specific order order. Compute a column B sequentially as B = MAX(0, LAG(B) - LAG(A)), starting with a default value of 0 for the first row.
Example:
Input:
order | A
------|----
0 | -1
1 | -2
2 | 4
3 | 4
4 | -1
5 | 4
6 | -1
Wanted output:
order | A | B
------|----|---
0 | -1 | 0 <- B here is here set to 0
1 | -2 | 1
2 | 4 | 3
3 | 4 | 0
4 | -1 | 0
5 | 4 | 1
6 | -1 | 0
Using the default F.lag window function does not work, since this one yields only the old previous row, since otherwise distributed computing is no longer possible, if it needs to be computed sequentially.
I currently have a table (data) containing many different data types however, I am trying to access the rows containing a certain Hex value in a column. Below is everything I have tried so far:
data=
Entry No | Time | Word
---------|-------------|-------
1 | 000:123:456 | 0123
2 | 000:123:457 | A0A0
3 | 000:123:543 | F0F0
4 | 000:124:123 | FFA0
5 | 000:124:987 | 2A0F
Msg = find(strcmp('F0F0', data.Col));
Msg = find(ismember(data.Col,'F0F0'));
Msg = strfind(data.Col, 'F0F0');
Msg = data(data{:, 20} == F0F0,:);
Due to the different datatypes in other columns I also cannot convert the table to an array.
If you have any suggestions on how I can do this, that would be great.
I have a query that returns a count of events on dates over the last year.
e.g.
|Date | ev_count|
------------+----------
|2015-09-23 | 12 |
|2016-01-01 | 56 |
|2016-01-15 | 34 |
|2016-04-08 | 65 |
| ...
I want to produce a graph (date on the X-axis and value on Y) that will either show values for all dates (0 when no data), or at least place the dates where there are values in a correctly scaled place for the date along the time axis.
My current graph has just the values one after another. I have previously used dimple for generating graphs, and if you tell it that it's a time axis, it automagically places dates correctly spaced.
This is what I get
|
| *
| *
| *
|*_______________
9 1 1 4
This is what I want to have
|
| *
| *
| *
|_________*________________________________________
0 0 1 1 1 0 0 0 0 .....
8 9 0 1 2 1 2 3 4
Is there a function/trick in BIRT that will allow me to fill in the gaps with 0 or position/scale the date somehow (e.g. based on a max/min)? Or do I have to join my data with a date generator query to fill in the gaps?
I have several spreadsheets for a SUS-Score usability test.
They have this form:
| Strongly disagree | | | | Strongly agree |
I think, that I would use this system often | x | | | | |
I found the system too complex | |x| | | |
(..) | | | | | x |
(...) | x | | | | |
To calculate the SUS-Score you have 3 rules:
Odd item: Pos - 1
Even item: 5 - Pos
Add Score, multiply by 2.5
So for the first entry (odd item) you have: Pos - 1 = 1 - 1 = 0
Second item (even): 5 - Pos = 5 - 2 = 3
Now I have several of those spreadsheets and want to calculate the SUS-Score automatically. I've changed the x to a 1 and tried to use IF(F5=1,5-1). But I would need an IF-condition for every column: =IF(F5=1;5-1;IF(E5=1;4-1;IF(D5=1;3-1;IF(C5=1;2-1;IF(B5=1;1-1))))), so is there an easier way to calculate the score, based on the position in the table?
I would use a helper table and then SUM() all the cells of the helper table and multiply by 2.5. This formula (modified as needed, see notes below) can start your helper table and be copy-pasted to fill out the entire table:
=IF(D2="x";IF(MOD(ROW();2)=1;5-D$1;D$1-1);"")
Here D is an answer column
Depending on what row (odd/even) your answers start you may need to change the =1 after the MOD function to =0
This assumes the position number is in row 1; if position numbers are in a different row change the number after the $ appropriately
I have the following matrix:
Design view
--------------------------
| OfficeSID | [Type] |
--------------------------
| [OfficeSid] | [Value] |
--------------------------
Preview
----------------------------
| OfficeSID | A | B |
----------------------------
| 1 | 1029 | 982 |
----------------------------
| 2 | 98 | 782 |
----------------------------
| 3 | 786 | 82 |
----------------------------
| 4 | 29 | 2 |
----------------------------
I want to format background color of the cells i.e 2nd row, 2nd column which is a value field. It is grouped under Type field.
The background color should be the following:
If value < 0 red
If value < 100 and > 0 Orange
If value >= 100 Green
I tried using expressions but it dint work.
This is a pretty common requirement... It sounds like you're trying to set the BackgroundColor property at the cell level, which is correct, so there's no reason it shouldn't be working.
What expression are you using? I'd use something like:
=Switch(Fields!Value.Value < 0, "Red"
, Fields!Value.Value > 0 and Fields!Value.Value < 100, "Orange"
, Fields!Value.Value >= 100, "Green")
Edit after comment:
Hmm, not sure what's going on with your report. I put together a basic example to match your results and it's working as expected.
Put together sample dataset:
Create matrix:
Expression for Value Text Box BackgroundColor property, literally copied and pasted from the answer above:
Final results, which looks like it's working as expected:
So I'm not sure what to suggest here... About the only thing I can think of is whether you have multiple values per OfficeSID/Type combination, in which case you'd need to use an aggregate in the expression, i.e. something like:
=Switch(Sum(Fields!Value.Value) < 0, "Red"
, Sum(Fields!Value.Value) > 0 and Fields!Value.Value < 100, "Orange"
, Sum(Fields!Value.Value) >= 100, "Green")
But other than that I guess you could either add the exact details of the data you're using, or start a new report from the ground up in the simplest way possible. This would show if you can get the background working in a new report with no other logic in place.