How to merge two data streams in Alteryx - append

Alteryx
Table 1 is a google sheet file. It has x fields with primary key.
Every day to that table is added the weekday with the x data
For example:
Monday
Tuesday (is added on Tuesday) and so on.
My problem is that my workflow has a formula that does calculations with all the Weekdays.
Example:
Balance = All_Income - Monday - Tuesday - Wednesday - Thursday - Friday - Saturday - Sunday
But today for example, in the google sheet data I don't have the other weekdays except Monday and Tuesday, so I get the error "Unknown Variable" for Thursday.
I've inserted a Text Input and added all the weekdays.
I want to (Append maybe) these two data streams together so that I have all the weekdays there.
So if I run the calculations I have all the weekdays there.
Right now that formula works only on Sunday, when all weekdays are inserted as columns.
Any idea how to achieve this?
(p.s Creating the weekdays as columns in the google sheet with empty rows is not an option).

I managed to do it by creating a Text Input with the same column names (headers) as the other Data Source and performing a union.
Apparently I needed to perform a IF statement to check all Weekdays if they exist and replace the null values with.
If anyone encounters the same error, feel free to contact for help :)

Use the Transpose tool to verticalise the days of the week. Then Summarize using the primary key and sum the [value] field. That will give you the balance regardless of which days of the week are present in your worksheet. This technique applies to any problem in which one needs to aggregate multiple fields which may or may not be present or known.
Here is the simplest path to victory:
1. Input worksheet.
2. Connect Transpose tool.
3. In Transpose Key Columns, select only primary key.
4. In Transpose Data Columns, deselect all fields except for days of week and Dynamic or Unknown Columns. This will still work even if the worksheet doesn't have all the days of the week because as they come in, the Dynamic or Unknown Columns option will select them as Data columns.
5. In Transpose Missing Columns, select Ignore.
6. Connect Summarize tool.
7. In Summarize, group by primary key and sum on [Value] field.
From here, you can rename the sum_value field to Balance or something else friendly. You can also use a Join tool, joining on primary keys, to the original worksheet to get back to where you started with the new aggregated value.

Related

How to correct the order of the year in Qliksense?

My data contain a column showing the year of each record, ranging from 2005 to 2017 I am using the Time Slide extension (https://github.com/caallard/Time-slide) to help me visualize the data. However, the order of the year is problematic.
As shown in the following plot, the first year in the slider is 2006, while the last year is 2005, which means the first year somehow shifted to the last.
I further checked my data. When I uploaded my data to the Qliksense, the preview of the data in the data manager window looks like the following. The year is not in the right order. Perhaps this is related to my question.
I would like to learn how can I fix this. Thanks.
Edit
I have a workaround for now. There are two tables in my Qlik sense both have a column showing Year. Previously I linked these two tables with the Year column. I just deleted that link, and reference my time slide to the Year column from the other table. The sequence of the year in my time slide is normal now.
Here is the preview of the year column from my other table. The order of the year is normal, and I believe since I added this column to my time slide, the order of the time slide is normal accordingly.
However, the original year column I showed before is still in the wrong order. This is strange.
Edit 2
If I select the Time Slide extension in edit mode, below is the available under the Dimension. For the Sort by Numeric and Sort by Alphabetical, they both have three options: No, Ascending, and Descending. However, switching between these options does not affect the order of the year in Time Slide.

Sum from/to date

I have 3 tables, one with stocktakes conducted last year, one with stocktakes conducted this year and one with sales. All of them are joined by date to one table where I have dates.
Now the question is what can I do to get table with:
store name/ last year stocktake date/ this year stocktake date/ sum of sales from last year stocktake date to this year stocktake date.
If you choose store, than stocktake date from one table, stocktake from second table all looks good, the problem is that I can't get sales to show from/to.
C2Csales = calculate(sum(PP_SalesLessTax[SalesLessTax]),PP_SalesLessTax[date] >= [ly date])
[ly date] is just a measure with last year stocktake date
I have a feeling that this have to be very easy but have no idea how to get this work
thanks
daniel
please see data model. It is a part of bigger model but I have trimmed it so it is clear what is this about.
data model
And here is what I need. Please see picture.
thanks for all responses
result required
You don't need two tables to simulate years. You can have just one. The idea of last year should be calculated by a measure. If you have a complete date table with a day for each row without missing days then you can build time intelligence.
If I get you, you need something like this two measures:
Sales = sum(PP_SalesLessTax[SalesLessTax]
Sales LY = CALCULATE ( sum(PP_SalesLessTax[SalesLessTax] , SAMEPERIODLASTYEAR ( DatesTable[DateColumn] )
With this two measures you can take both of them on same visualizations to compare them.
The idea of having from and to can be solved on visualizations. The slicer with a date type column can create a range filter data that will apply for this two created measures.

Crystal Reports - create calendar

I need to create an attendence list showing days in rows and employee names in colums. The list will always cover one full month chosen in parameters.
How can I create a recordset of days of chosen month? I've done it in command section but, due to ERP system limitations, it must done otherways.
Thank you,
Przemek
A good approach is to create a Calendar table (aka Date Dimension in data warehousing lingo). It makes it easy to show days without any attendance. If you don't need that aspect, you can simply create a formula that returns the attendance date month's day, and Group on that formula. The Day() function gets you the day of month. For example,
Day ({Orders.Order Date})
If you search 'creating a data dimension or calendar table' you'll find many helpful sources such as this one: https://www.mssqltips.com/sqlservertip/4054/creating-a-date-dimension-or-calendar-table-in-sql-server/
For your case, I agree with the comments in that post about using date instead of integer as the primary key. Integer PK makes more sense for true data warehousing scenarios as opposed to legacy databases.

Creating Bins in Tableau for Days in a Week

Could someone please explain me creating BINS based on Weekdays in Tableau? I tried creating different Calculation Fields but it won't work
You're working too hard.
Tableau already knows how to bin values by dates at many levels of granualarity: such as year, month, day, weekday, hour etc. So you don't need to create a new field to bin dates by the day of the week. (creating bins is not difficult, it's just already available in this case)
Just put a discrete (blue) date or datetime field on a shelf. You'll see the date level of granularity displayed like, say, YEAR(MyDateField) with a leading plus sign.
You can either
click on the plus sign to drill down by adding a second level, say MONTH(MyDateField)
or
right click on the field to select the date level of granularity you want
Alex's Answer is exactly correct, Tableau will perform the operation automatically. What is great about is that you can select various formats (Full day name, number, 1 letter or 3 letter day etc.).
However if you absolutely need to you can used this formula:
datepart('weekday',[Date])
to give you the 1 (Sunday) to 7 (Saturday) value if you need it for something other reason, say another calculation.

Filter data by different time intervals

I need to filter my query with different time intervals like that:
...
where
date >= '2011-07-01' and date <='2011-09-30'
and date >='2012-07-01' and date >='2012-09-30'
I suppose such code is not good, because these dates conflicts with each other. But how to filter only these two intervals, skipping everything else? Is it even possible? Because if I query like this, I don't get any results.I tried to use BETWEEN, but it does same thing.
I bypassed this by extracting quarters from years and calculating only third quarter. But then other quarters sum is showed as zero and I can't ignore these rows that have sum column with zero value. I tried to filter where price > 0 (column where sum goes), but it says that column do not exist. So I put it whole FROM under '('')' brackets to make it calculate sum before where clause, but it still does give me error that such column do not exist.
Also if you need to see query I have now, I can post it, just tell me if it is needed.
I want to do this, because I need to compare third quarter of two different years (maybe I should use another approach).
You're not going to get any results because you can't have a date that's both within 7/1/2011 through 9/30/11 and after 7/1/2012 and after 9/30/12.
You can have a date that is either between 7/1/20122 and 9/30/2011 or between 7/1/2012 and 9/30/2012.
SELECT col1 FROM table1
WHERE date BETWEEN '7/1/2011' AND '9/30/2011' OR date BETWEEN '7/1/2012' AND '9/30/2012';