Datacrawler
Datacrawler

Reputation: 2886

Tableau SUM of records is wrong after linking datasets

I have two datasets on Tableau. They are originally csv files that I import.

The first has this fields :

And the second one those :

In the columns I put the "SUM(Number of Records)" and in the rows I put the "Device". I am joining the two datasets by linking the "Name" and the "Date".

enter image description here

The first dataset has three different devices : 'desktop', 'mobile', 'tablet' and the second one has only 'desktop'. I get the SUM of records for the device of the 1st dataset only (the result is correct).

enter image description here

I am new in Tableau and I want to get the results from there. I know how to make it work in mysql by joining the tables but I want to learn dealing with Tableau only.

Upvotes: 0

Views: 2345

Answers (1)

bitlamas
bitlamas

Reputation: 742

When you link the two data sources, it doesn't mean the Number of Records will have both results. From the image, I can see you used the field from the Primary Data Source, so naturally it'll only count those results.

What you're looking for is a calculated field containing both devices. In this case you have to link both data sources (as you did) and create a calculated field like this:

COUNT([Device]) + COUNT([Dataset 2].[Device])

Here you can see that we are actually adding the count of both Devices (the first field from Dataset 1, our primary data source, and the second from Dataset 2). Remember: when referring a field from a secondary data source, you always need to indicate it in the formula.

Use your new calculated field in the Columns section to get the correct numbers.

Upvotes: 1

Related Questions