When I graph data in AWS CloudWatch Log insights, bar graphs are ordered Most Recent to Oldest (left to right) while Line Graphs are ordered Oldest to Most recent (left to right) this seems to occur despite setting sort values. Here is an example query:
fields #timestamp, link_count
| sort #timestamp desc
| filter ispresent(link_count)
| stats avg(link_count) as Links by bin(1d)
I would like the x-axis on my bar graph to follow the same order as the line graph. It doesn't really matter which direction as long as both go in the same direction. Is this possible?
Observe the x-axis values in each of these graphs:
Line Graph Visualization
Bar Graph Visualization
I came into the same issue, and solved it. But I was using other functions instead of avg(). So maybe this could work for you as well:
The trick is to give bar a name, and then sort the name
...
| stats avg(data) by bin(1d) as data_name
| sort data_name
Related
I wanted to show the number and status of Redmine bugs per day through Grafana. My X-axis is time, and as time goes on, my bar graph is sometimes uneven, and I don't know what's going on. Does anyone know how to do to make my bar graph even?
My SQL:
SELECT
$__timeGroup(created_on, "1400m") AS time_sec,
count(*) as value,
is2.name
FROM issues i
left join issue_statuses is2 on is2.id = i.status_id
WHERE
$__timeFilter(created_on) and to_days(now())-to_days(created_on)<7
group by time_sec,is2.name
Your dashboard time range has To: now - so, that's current time.
Use now/d in To - that's end of current day (and also now-7d/d will be good From in this case).
I am doing campaign analysis in Tableau where I want to see the percentage of leads that has seen 1 campaign,percentage of leads that has seen two campaign and so on in pie chart filter by month and region before they convert to customer.
For e.g in below sample data set there are 5 leads in February of which only lead id abc has seen two campaigns and rest four has seen one campaigns. So the view will be pie chart where 20%(1 out of 5) of lead has seen two campaigns and rest 80% has seen 1 campaigns. If March is selected then pie chart will be 100% one campaign as there is only 1 lead.
If in region filter US is selected then there are three unique leads(abc,efg,klm) in february and view will be pie chart with 33% lead has seen two campaigns and rest two i.e 77% has seen 1 campaign.
I got idea from the link here but not able to do it when month and region filter is added.
Campaign analysis in Tableau
Just add two calculated fields both LOD, as detailed below-
Campaigns per Lead as
{ FIXED [Lead id] : COUNT([Campaign])}
'Measure_val` as
COUNTD([Lead id]) / ATTR({ FIXED : COUNTD([Lead id])})
Format Measure_val as per cent in number format.
Add your filters to view, add both filters to CONTEXT by right clicking them (Note: In order to have filters calculated before LOD calculation. Normal filter calculates the view after LOD fields are calculated). Check whether filters have been greyed out.
Convert Campaign per Lead to dimension by right clicking it.
Add Measure_val to size, angle and text(for label-optional) and Campaign per Lead to color and text(optional again) and you're done.
Do tell if it worked.
Trying to figure out tableau calculated fields:
I would like to calculate the occurrence of a row variable. Example:
Fruit | Occurrence
Apple | 2
Apple | 2
Orange | 1
Banana | 1
Occurrence should be the calculated field which in Excel would be =COUNTIF([fruit]=[#fruit])
What's the equivalent syntax for Tableau?
Just take in consideration that if you use "FIXED" the filters won`t wot
I suggest to use "INCLUDE"
{INCLUDE[Fruit] : COUNT([Fruit])}
My solution works with WINDOW calculations. Also, it requires data disaggregation: Tableau online documentation
Code for discrete Calculation2 (Compute using PANE DOWN):
RUNNING_COUNT(ATTR([Fruit]))
Code for discrete Calculation3 (Compute using PANE DOWN):
WINDOW_MAX([Calculation2])
Whether or not this still works when you shuffle around the values in the data source, I do not know. You would need sorting for the Fruit column then, I guess.
I've realised the right answer is:
{FIXED [Fruit] : COUNT([Fruit])}
Where fixed creates a set array filtering the all rows containing the current row's same variable.
I have a dataset with three fields: region, product, sales. I would like to display by-region bar charts of sales by product, with bars sorted within each region. I follow the recipe on
http://kb.tableau.com/articles/knowledgebase/nestedsorting
until I get to Step 4, at which point Tableau (9.2) shows me this.
What went wrong? And how do I get my nested sort?
... turns out I can do the desired sort this way.
I am working on putting finishing touches on a tool after a developer abruptly quit and left no documentation. I have been able to fix everything except for the following.
I am creating a bar chart using data from a select query:
Date Facility Bucket Variance
2/5/15 A >$10k >90 -2.1234
2/5/15 A >90 -10.567
... ... ... ...
Using the chart wizard, I select Data: Variance, Axis: Bucket, Linked fields: Facility, Date (users can select these from the main form).
The chart itself looks perfectly fine, but in the main form a navigation bar appeared, giving me the option to switch between 6 records. Switching changes the graph in no way, shape or form.
http://i.imgur.com/qq6xiqi.png
While I can disable/hide the bar, whatever thing caused it to believe there were six unique records makes it print the same chart 6 times when printed or sent to PDF.
http://i.imgur.com/la9JBCs.png
Any idea what is causing this, and how I can prevent it?
Thanks!
EDIT: I should add that there are 6 unique values for facility and bucket. Date, Facility and Bucket make up the primary key for their table.
EDIT2: It's the Bucket causing this. Joining a facility filter table with the query did nothing.
EDIT3: Record Source query
SELECT tbl_Trending_Data.Date, tbl_Trending_Data.Facility, tbl_Trending_Data.Bucket, IIf([Target] Is Null,Null,[Days]-[Target]) AS Variance
FROM tbl_Facility_Filter INNER JOIN tbl_Trending_Data ON tbl_Facility_Filter.Facility = tbl_Trending_Data.Facility
ORDER BY tbl_Trending_Data.Bucket;
Change your recordsource query to:
SELECT TOP 1 tbl_Trending_Data.Date, tbl_Trending_Data.Facility,
tbl_Trending_Data.Bucket, IIf([Target] Is Null,Null,[Days]-[Target]) AS Variance
FROM tbl_Facility_Filter
INNER JOIN tbl_Trending_Data
ON tbl_Facility_Filter.Facility = tbl_Trending_Data.Facility
ORDER BY tbl_Trending_Data.Bucket;
You need to limit it to TOP 1 so that you're only looking at the first row. That will stop the program from printing multiple records/charts.