Conditional Formatting reset on group change - crystal-reports

I have a report that shows a comparison of MPG a certain vehicle got from last year and this year. I want to highlight the current year's MPG in relation to whether it is greater or less than the previous year. If MPG has improved in the current year, I want the number to show green, if it is less than previous year, I want it to show red. I have two formulas that calculate the MPG, one for each year. In the Section Expert, I go to font and enter this in the font forumla:
if{#Current Qtr MPG}>={#Previous Qtr MPG} then crGreen else
crRed
However, the highlight isn't quite right. The result is that ALL the current year values have been turned green, even if they are less than the previous year and only 0 values have turned red. I suspect this has something to do with needing to reset the formatting formula at each group level, but I'm unclear on how that's done.
This may seem similar to this other post of mine, but it is different. In the first post, both values I wanted to compare were from the same field on different rows. This post is a simpler questions because I'm attempting to highlight one field based on how it compares to another separate field.

Related

DateDiff calculation in Tableau

I am trying to calculated the number of days it takes to get approved. So ideally it would show the date diff from Pending review to Approved.
The formula I used to calculated date diff is showing the date diff from the previous row.
This works however I want the calculation to be applied for each Parent ID. Otherwise at the start of each record it is showing a negative date diff because its calculating between 2 different parent ID.
The formula I used to calculated date diff is showing the date diff from the previous row.
This works however I want the calculation to be applied for each Parent ID. Otherwise at the start of each record it is showing a negative date diff because its calculating between 2 different parent ID.

Power BI - Calculating a price/cost until a variable end date

Let's say I have a table of projects/programs/subscriptions/etc, it doesn't really matter as long as there is a price or cost per some amount of time. My table includes at least the following columns:
[ProjectName]
[StartDate]
[EndDate]
[CostPerDay]
I'm trying to allow the user to choose another date (slicer I assume?) and display the cost of each and all projects up to that date. Is this possible?
Edit: After the first responses I realize the original question was very poorly worded. Sorry about that. I've reworded it and I'll explain more here:
I am not trying to filter the programs by end date. I'm trying to sum a cost up until the end date OR slicer date, whichever is earlier.
Here's a short example table:
So we can also think of it as a Gantt chart like this:
Now imagine sliding a vertical line along that chart. I want to see the total cost up to that date.
I'm sure it will have to do with counting days between start date and the slicer date, then multiplying by cost. But how do we not include days after the end date of each project? Or it may be easier to do a range slicer with a min and max date, but again not counting days before or after each project.
To word it differently: can I input a date range, count the days that each project has in common with that range, and (the simple part) multiply days by cost?
It looks like what you need is a table visualization with a slicer for End date. Once the table and slicer are created, you can click on the small down facing arrow in the slicer and choose "Before". If you want both start date and end date in the equation, then you would have to add one more slicer for "Start date". If this is not what you are looking for kindly provide additional details so that we can help you out.

How to draw continues lines across panels in Tableau

I want to plot a couple of measures by months over the last three years. The plot would be divided by year. So I put year and month for columns and the measure values for rows. The year is defined as DATEPART('year', [Month Date]) and month is DATEPART('month', [Month Date]).
The plot looks like this.
The lines are broken between years. Both YEAR and MONTH are blue (discrete), but if I change them to green (continuous), the lines are connected but it looks weird.
I wonder how to make continuous lines across year?
What has happened is you have converted a date part (i.e. Month = March) to a continuous unit. What this does is simply changes March to 3. This looses the context of what the actual date is (i.e. March 2007). To change this right click on the date field on the column. You will see two separate areas to format the dates i.e. there are two years (2015, 2015), two quarters (Q2 and Q2 2015) etc. The first is a date part and the second is truncated date from the original date/timestamp.
You want to change the format to the second Month option (Month May 2015) and ensure the data type is continuous.
This should give you a continuous line across the year. If not screenshot me where you get to and I can assist from there.
Check if the last week and first of the next year is the same, I have a similar issue and solved it by passing the dates as Day-Month-Year.

Aggregating data from the US stock market in Tableau, using different time frames

I am a very basic user of tableau and I have not found an answer to my question.
I have a txt file that has historical daily data for 98% of all the stocks in the US, with their daily capitalization. Each stocks has its TICKER, Daily Market Value for every trading day of the year, and its SECTOR.
I did a simple time series that display SUM([Mktval]) (sum of all individual market values) across all stocks, on a daily daily, and where I can see that the total value as of 2016 is about 24 Trillion USD, as in the image below.
When I change the view column from DAY to YEAR, I don't see the right values, but something a lot larger. So I realized that I need to do SUM([Mktval])/252 to get the right value for a year (there are 252 trading days in a year).
If I change the view to MONTH, as in the chart below, the numbers are again wrong because 252 is not the right value to use in the division.
Is there any way that Tableau can adjust the values automatically to reflect the AVG MktVal across different time intervals?
Thanks
Replace SUM(Mktval) on the Rows shelf with the following calculated field
avg({ fixed day(Date1) : sum(Mktval) })
That solution is all in one step. It is perhaps a bit more clear to use 2 steps. First, create a calculated field called total_daily_market_value defined as
{ fixed day(Date1) : sum(Mktval) }
Then make sure that calculated field is a measure. It is an LOD calculation that you can think of as a separate table with one value for each day showing the total market value for that day.
Drag that measure to a shelf, and then change the aggregation function to AVG(), MEDIAN(), MIN(), MAX() or STDEV() as desired. Tableau will aggregate the total_daily_market_value using your chosen aggregation function for whatever values of Date1 are in your view.

Require minimum number of data points before plotting a point in Tableau

Can I cause Tableau to require a certain number of underlying data points before plotting a point on the graph?
For example, here's a graph showing average moods over the course of the day on Tuesdays:
There's nothing uniquely awful about midnight on Tuesdays, it's just that there's only one data point for that particular time, and it's an outlier. Is it possible to have the graph show midnight as missing unless there are more than (for example) three different records from midnight being averaged together?
You could define an aggregate calculated field, called say avg_mood as:
if count(Mood) >= 3 then avg(Mood) end
Since the aggregation is hard coded into the calculation, Tableau will display AGG(avg_mood) for the field on any shelves you use it on, rather than letting you toggle the aggregation outside the formula as it will for other measures.
Note, there is no else branch, so the calculation will evaluate to null if there are less than three non-null Moods in a partition of data rows (based on the dimensions)
You can control how null values are displayed in a line chart. On the format pane, select the field in question from the pull down menu by the word Fields at the top right of the format pane, then select the Pane tab, then at the bottom of the format pane, adjust the Mark settings in the Special value section.