I am coming across an issue wherein I am trying to lookup a Cost to a file with multiple rows for a project, but it's not working out, as lookup is repeating the cost for all the rows and thereby not providing the correct cost associated with a project. Here is how the file looks in which I am trying to lookup the value:
Date Project
1/08/2017 XYZ
2/08/2017 XYZ
3/08/2017 XYZ
4/08/2017 XYZ
5/08/2017 XYZ
6/08/2017 XYZ
1/09/2017 ABC
2/09/2017 ABC
3/09/2017 ABC
4/09/2017 ABC
5/09/2017 ABC
6/09/2017 ABC
12/10/2017 DEF
13/10/2017 DEF
11/11/2017 IJK
And here is the file form which I am trying to lookup the value from:
Project Budget
XYZ 200000
ABC 300000
DEF 1000000
IJK 50000
Any help is highly appreciated. Also how can I count a project is repeated in the field. I am looking for something like this :
Date Project Count_Projects
1/08/2017 XYZ 6
2/08/2017 XYZ 6
3/08/2017 XYZ 6
4/08/2017 XYZ 6
5/08/2017 XYZ 6
6/08/2017 XYZ 6
1/09/2017 ABC 6
2/09/2017 ABC 6
3/09/2017 ABC 6
4/09/2017 ABC 6
5/09/2017 ABC 6
6/09/2017 ABC 6
12/10/2017 DEF 2
13/10/2017 DEF 2
11/11/2017 IJK 1
I really need to figure this out.
For your second question, you can create the Count_Projects calculated column as follows:
Count_Projects =
CALCULATE(DISTINCTCOUNT(Dates[Date]),
FILTER(Dates, Dates[Project] = EARLIER(Dates[Project])))
Or you can use a variable:
Count_Projects =
VAR Project = Dates[Project]
RETURN CALCULATE(DISTINCTCOUNT(Dates[Date]),
ALL(Dates), Dates[Project] = Project)
Like #Alexis Olson, I'm not clear as to exactly what output you expect; but, assuming that you want to see the same Budget number listed for each respective Project entry (e.g., 200000 for each instance of XYZ, 300000 for each instance of ABC, etc.), here's an answer.
If you've got both tables loaded into PowerBI, As seen from the right side of the screen in the Data view (I named them Table and TableLookup):
If you click Home -> Manage Relationships, you'll see there is a relationship between the two tables:
If you then click Edit..., you'll see it's a Many to one relationship between the overall table (I called it Table) and the lookup table (I called it TableLookup):
Anyhow, the point is...there is a relationship between the two tables, and you're going to use it.
Click Cancel.
Click Close.
Click Modeling -> New Column; then, in the formula bar, type:
Budget = RELATED(TableLookup[Budget])
and enter. You'll get this:
Then you can do what Alexis said for counting:
Click Modeling -> New Column; then, in the formula bar, type:
Count_Projects =
CALCULATE(DISTINCTCOUNT('Table'[Date]),
FILTER('Table', 'Table'[Project] = EARLIER('Table'[Project])))
I replaced Alexis's "Date" with "Table" because my table is named Table.
You'll see this:
Related
My database query fetches list of data like:
id key noc date
1 abc 4 1-10-2016
2 abc 12 2-10-2016
3 abc 23 3-10-2016
4 abc 2 4-10-2016
5 def 23 1-10-2016
6 def 44 2-10-2016
7 def 12 3-10-2016
9 def 43 4-10-2016
10 def 43 5-10-2016
abc and def made those no of calls on those dates.
I want to display these data in chart.
But I am fetching this data with a single query, and I want to create 2 charts , one for abc and another for def.
How can I create multiple charts in jaspersoft with single query and making a single chart? As the number of persons making the call can be different , and I will have to create a chart for every person.
When creating or modifying each chart you just need to link them back to the relevant dataset. This can be either the main report dataset or a sub-dataset created just to run the charts.
You only need to follow the instructions on the relevant jaspersoft wiki page and link each new chart back to the required dataset.
Regards,
For getting multiple charts from a single query you need to do :
First create a jasper report, and add a subreport to it. ( Make sure to make the layout growable and the width of the main group should be larger than the subgroup)
Create the dataset
Create Group on right clicking the report from outline panel.
Provide a group name by selecting a column.
Add a expression pointing the column which is grouping the data.
And select reset on group .
Don't forget to set the evaluation time and the evaluation group
For example :
<chart evaluationTime="Group" evaluationGroup="KeywordGroup">
I am quite new to Tableau, so have patience with me :)
I have two tables,
Table one (T1) contains all my data with the first row being Year-Week, like 2014-01, 2014-02, and so on. Quick question regarding this, how do I make Tableau consider this as a date, and not as string?
T1 contains a lot of data that looks like this:
YearWeek Spend TV Movies
2014-01 5000 42 12
2014-02 4800 41 32
2014-03 2000 24 14
....
2015-24 7000 45 65
I have another table (T2) that contains information regarding some values I want to multiply with the T1 columns, T2 looks like:
NAME TV Movies
Weight 2 5
Response 6 3
Ad 7 2
Version 1 0
I want to create a calculated field (TVNEW) that takes the values from T1 of TV, and adds Response(TV) to it, and times it with the weight(TV),
So something like this:
(T1[TV]+T2[TV[Response]])*T2[TV[Weight]]
This looks like this for the rows:
(42+6)*2
(41+6)*2
(24+6)*2
...
(45+6)*2
So the calculation should take a specific value from T2, and do the calculation for each value in T1[TV]
Thanks in advance
The easy answer to your question will be: No, not natively.
What you want to do sounds like accessing a 2 dimensional array and that's not really the intention of Tableau. Additionally you have 2 completely independent tables without a common attribute to JOIN on. Tableau is just not meant to work that way.
I cannot think of a way to dynamically extract that value (I assume your example is just that, an example; and in your case you don't just use two values in the calculation, otherwise you could create 2 parameters that you can use in your calculated fields)
When I look at your tables it looks like you could transpose and join them that they ideally look like this: (Edit: Comment says transposing is not an option)
Medium Value YearWeek Spend
Movies 12 2014-01 5,000
Movies 32 2014-02 4,000
Movies 14 2014-03 2,000
Movies 65 2015-24 7,000
TV 42 2014-01 5,000
TV 41 2014-02 4,000
TV 24 2014-03 2,000
TV 45 2015-24 7,000
and
Medium Weight Response Ad Version
TV 2 6 7 1
Movies 5 3 2 0
Depending on the systems you work with you could already put it in one CSV or table so you wouldn't have to do a JOIN in Tableau.
Now you can create the first table natively in Tableau (from Version 9.0 onwards), if you open your data source, in the Data Source Preview choose the columns TV and Movies, click on the small triangle and then on Pivot. (At this point you can also choose the YearWeek column click on the triangle and Split to create a seperate field for Year and Week. You won't be able to assign the type date to it put that shouldn't give you any disadvantages.)
For the second table I can think of two possibilities:
you have access to a tool that can transpose your table (Excel can do that see: Convert matrix to 3-column table ('reverse pivot', 'unpivot', 'flatten', 'normalize') Once you have done that you can open it in Tableau and join the two tables on Medium
You could create calculated fields depending on the medium:
Field: Weight
CASE [Medium]
WHEN 'TV' THEN 2
WHEN 'Movies' THEN 5
END
And accordingly for Response, Ad and Version
Obviously that is only reasonable if you really just need a handfull of values.
Once this is done it's only a matter of creating a calculated field with
([Value]+[Response])*[Weight]
And this will calculate all the values for your table
I have yearly data in my excel file in such format:
Country \ Years 1980 1981 ... 2010
Abkhazia 234 334 ... 456
Afghanistan 466 789 ... 732
...
Here is picture
And I want my data transform to 3 different tables and load it to postgres database.
Tables should look something like that
First table - country:
id | name
1 | Abkhazia
2 | Afghanistan
Second table dates:
id | date
1 | 1980
2 | 1981
And third is a table where all data is stored depending on country and date:
country_id date_id data
1 1 234
1 2 334
2 1 466
2 2 789
... ... ...
Any ideas how I could achieve my goal?
Assuming the source excel structure is as below (i have custom built this):
There are basically 3 parts to your question. I break down the transformation into part for better understanding:
1. Loading Table - Country
This is pretty straight forward based on the data given in the excel. Simply take an
Excel Input >> Add a sequence step. Give the Sequence name as Country ID >> Select only the Country Name and Country ID >> Load into the Country Table using Table Output.
2. Loading Table - Year:
The idea here is to display the Year ID in Row wise format instead of the columns given the excel source data. PDI version 5 and above provides you with a very useful step called Metadata Structure. This step allows you to get the structure of your table. In this case, we need to have the year columns pulled, ignoring the country column.
Follow the steps as below:
Read the Excel Data >> Get the Metadata structure of your source >> Filter Out the Country Column (which is available in row at position=1) >> Add a Sequence Number. Name it YearID >> Finally Load the Year Table.
3. Loading the Final Table - Country and Year along with Data:
The way to display all the column data values to a row level in PDI is using Row Normalizer step. Use this step to display a normalized output. Now follow the below steps:
Read the Excel source data >> use Row Normalizer Step to normalize the rows based on the Years >> Do a Stream Lookup with the Above Country and Year tables to fetch the CountryID and YearID respectively >> Finally Load the necessary column data into Table Output
Hope it helps :)
I have placed the codes in github repo along with the data file which i have used. Its here.
Also, just realized that i have given the wrong naming conventions as per your question. Consider date_id as YearID and instead of id's i have given countryid and yearid.
I'm new to KDB ( sorry if this question is dumb). I'm creating the following table
q)dsPricing:([id:`int$(); date:`date$()] open:`float$();close:`float$();high:`float$();low:`float$();volume:`int$())
q)dsPricing:([id:`int$(); date:`date$()] open:`float$();close:`float$();high:`float$();low:`float$();volume:`int$())
q)`dsPricing insert(123;2003.03.23;1.0;3.0;4.0;2.0;1000)
q)`dsPricing insert(123;2003.03.24;1.0;3.0;4.0;2.0;2000)
q)save `:dsPricing
Let's say after saving I exit. After starting q, I like to add another pricing item in there without loading the entire file because the file could be large
q)`dsPricing insert(123;2003.03.25;1.0;3.0;4.0;2.0;1500)
I've been looking at .Q.dpft but I can't really figure it out. Also this table/file doesn't need to be partitioned.
Thanks
You can upsert with the file handle of a table to append on disk, your example would look like this:
`:dsPricing upsert(123;2003.03.25;1.0;3.0;4.0;2.0;1500)
You can load the table into your q session using get, load or \l
q)get `:dsPricing
id date | open close high low volume
--------------| --------------------------
123 2003.03.23| 1 3 4 2 1000
123 2003.03.24| 1 3 4 2 2000
123 2003.03.25| 1 3 4 2 1500
.Q.dpft will save a table splayed(one file for each column in the table and a .d file containing column names) with a parted attribute(p#) on one of the symbol columns. Any symbol columns will also be enumerated by .Q.en.
I have a report having a command object where I have empno and some columns. And I have another command object which also having empno.
For 1st command the parameter is division and based on division I will get some empnos in 1st commnd object and I need to pass this empnos from 1st command object to 2nd command object.
So that the 2nd command object should get some empnos from 1st command object and should display countries based on the matched empnos .
So I linked both command objects empnos in links tab.
Due to some performance issue I am doing like this
Created a sub report with 2nd command object and created empno parameter. Now in sub reports links tab I am passing main reports empno to sub reports empno parameter.
But I am getting non matching empnos data.
Please suggest
Here what I observed in my 1st table have data like this.
eno name division
1 aaa 2
2 bbb 2
3 ccc 2
In my 2nd table I have data like this
eno country division
1 India 2
2 Aus 2
By using 1st method(linking command objects in links tab).
I am getting result like this.
eno name division country
1 aaa 2 Ind
2 bbb 2 Aus
By using 1st method(Sub report approach).
I am getting result like this.
eno name division country
1 aaa 2 Ind
2 bbb 2 Aus
3 ccc 2
I need to get only employees present in both tables using sub report approach.
Please suggest
Hi Siva i am unable to post the image I am getting data like this.In my 2nd table I have onlt enos 1 and 2 .But I am getting all the emps even I used record selection formula also
**eno name division country
1 aaa 2 Ind
2 bbb 2 Aus
3 ccc 2**
when you use sub report for this purpose then you should not link parameters of main report to sub report instead you should use the linked parameter in Record Selection Formula of sub report then your filtering applies to sub report.
for e.g:
pass the parameter to sub report through links (Take care dont link the parameters) then you will get siomething like this {pm-parameter1}.
then go to record selectoin formula and write as
database field = {pm-parameter1}