Amazon Quicksight: is there any way to use 2 dates as X axis? - charts

In Quicksight, I have data like this:
What I am trying to do:
I want a chart that shows the sum of amount over created_date WITH the sum of amount over resolved_date (that second part is the challenge, the first one is easy). So it is kind of using dates as an X-axis, just that they are different date fields (created_date and resolved_date). Is there a way of doing this?

Related

Cumulative Values on Missing Data Quicksight

I'm trying to create a cumulative quarterly count divided by week. I have the underlying table that looks like this:
Date
Id
01/01/2022
X
02/01/2022
Y
The result is this
Screenshot of the problem](https://i.stack.imgur.com/9tmFA.png)
There are some white spaces due to particular weeks where there are no data. I would like to fill these blank spaces with the value of the week before (as it should be on a cumulative count) and with zero if it's the first week of the quarter.
Is there a way to solve this problem without creating any support table or any "fake data" to avoid the cell to be blank?

Power BI - Timeseries compare two different start dates

I want to compare how different campaigns are progressing based on number of days into the campaign rather than by date (see day1, day2, etc... on the x-axis below).
Here is my DAX code, but I can't get it to work. Any help would be much appreciated...
**Normalised Campaign Metrics =
VAR DateReached = CALCULATE(MIN(Days[Day]),db[PAYMENT_DATE]<> BLANK(), KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR MaxDate = CALCULATE(MAX(db[PAYMENT_DATE]),KEEPFILTERS(db[PRODUCT_CODE SWITCH]))
VAR DayNo = SELECTEDVALUE(Days[Day])
RETURN CALCULATE(count(db[PAYMENT_DATE]),
FILTER(ALL(db[PAYMENT_DATE]),
DateReached+DayNo && DateReached+DayNo<=MaxDate))**
Many thanks!
enter image description here
I would recommend solving this through manipulating your actual data rather than a complex DAX measure. If you are familiar with star schema modelling, I would solve this problem by adding a new column to your fact table that calculates how many days from the start date the payment occurred and then connect this column to a new "Days Passed" dimension that is simply a list of numbers from 1 to however many days you need. Then, you can use this new dimension as the source data for your x axis and use a standard payment amount measure for your y axis.
I recommend to create a dimension table as the relative basis to comparison with inactive relationship. Here is a video about it:
https://youtu.be/knXFVf2ipro

Spotfire: Empty values on x-axis

Spotfire question: I have a data table with monthly data that is visualized in a bar chart. I however also want to visualize the information in quarters, by showing the latest month of the quarter in the format '20Q1, 20Q2, etc.'. (So I don't want to use standard 'date format'.)
My idea was to create an additional column that is filled for March, June, Sep, Dec and empty for the other months. Then with a document property, the user can select to either view the data in months or in quarters (i.e. the last month of the quarter).
So far so good, my data now looks like this:
Month
Value
YearQuarter
Jan-20
100
Feb-20
200
Mar-20
400
20Q1
Apr-20
125
May-20
101
Jun-20
300
20Q2
The problem now is that when I visualize the data with YearQuarter on the x-axis, it also shows all the (empty) values in a bucket. See below. How to solve this? Note that the x-axis has a custom expression "<$esc(${Granularity})>", where Granularity is a document property to determine what column to pick.
Did you try limiting your data with whatever expression you have put in x axis.
Thanks

How to sum data if it falls under any arbitrary number of date ranges

I need a single formula for summing numbers that fall within an arbitrary number of date ranges.
You can use multiple SUMIFS() for each date range and then sum the result of those SUMIFS()s within a single cell like this:
=SUMIFS(dataRange, datesRange,">="&startDate, D:D,"<="&endDate) +
SUMIFS(dataRange, datesRange,">="&startDate, D:D,"<="&endDate) +
SUMIFS(dataRange, datesRange,">="&startDate, D:D,"<="&endDate)
But this requires that I know exactly how many date ranges I'm going to have.
For my spreadsheet I won't know how many date ranges I will have, so it has to dynamically grab the dates ranges.
Sample Google Spreadsheet (currently editable, please feel free to use)
You can use SUMIF in conjunction with the SUMPRODUCT function that multiplies components in the given arrays, and returns the sum of those products.
This can be done as below:
=SUMPRODUCT(SUMIFS(E:E,D:D,">="&A4:A100,D:D,"<="&B4:B100))

Creating a "stacked" Gantt chart in Tableau?

I'm working with a dataset that describes contract durations with a list of companies. Obviously all contracts have a start date and a (minimum) duration. Some contracts however, are subject to possible prolongation. Here's a data example:
Company contractStart minDuration firstProlong secProlong
Company x 27-11-2011 27-11-2014 27-11-2015 27-11-2016
Company y 29-11-2014 29-11-2015
Company z 01-04-2011 01-12-2011 01-12-2015 01-12-2017
I want to visualize them in a Gantt'ish type diagram that has duration along the x-axis, and shows the respective contract lengths with the possible prolongations as a sort of stacked bar chart. Along with that I want something to mark the current date. I've managed to do this in Excel. See picture:
.
I would however really like to be able to the same thing in Tableau, and I really can't figure out how to. I've been working with two different approaches so far:
1st approach
Here I drag the Company to the Rows shelf, and the contractStart date to the Columns shelf. I then create a calculated field that calculates (with DATEDIFF) the difference in days between the contract start and the minimum duration. I can drag that to the Size shelf, set the mark type to Gantt bar, and get something like this:
I can then go on to calculate the date difference between the minimum duration and the 1st prolongation and the same for the 1st and 2nd duration. The problem here is that I can't add these calculated fields to the Size shelf as it can only hold one at a time.
2nd approach
Here i reorganize my data like this:
Company Type startDate endDate
Company x minDuration 27-11-2011 27-11-2014
Company x firstProlong 27-11-2014 27-11-2015
Company x secProlong 27-11-2015 27-11-2016
Company y minDuration 29-11-2014 29-11-2015
Company y firstProlong
Company y secProlong
Company z minDuration 01-04-2011 01-12-2011
Company z firstProlong 01-12-2011 01-12-2015
Company z secProlong 01-12-2015 01-12-2015
I then create a calculated field to find the difference in days between startDate and endDate. I drag that to the Columns shelf and drag Company to the Rows shelf. I then drag Type to the Color shelf, set the mark type to Bar, and get something like this:
The problem here is that I need dates along the x-axis not integers. Also I need to be able to sort the chart like my initial Excel example. I.e. I want to sort on the longest possible duration of a contract (ascending). Also having to reorganize all my data seems a bit tidious.
Here's the spreadsheet and the tableau file I've been working with. Am I overlooking something really simple?
Your approach 2 is close. instead of sum(datediff) on the columns, place StartDate as continuous. Then place sum(datediff) on size. You can now sort Company ascending on sum(datediff). Sometimes, reorganizing data is necessary.