1 Reply Latest reply on Apr 4, 2018 10:01 AM by Deepak Rai

    SUM IF only if one value exists in a different data source

    Leah Adams

      Hi,

       

      I have relatively basic knowledge of Tableau and I currently have 2 data sources which are linked by a common field (style code). I am trying to get the units sold from data source 1 when the style code exists in data source 2 and the style status in data source 2 is active (as opposed to dropped).

       

      I've got as far as creating a calculation which gives me a 'YES' or 'NO' value when a style code appears in data source 2:

      IF ISNULL(ATTR([data source 2].[Style Code])) THEN "NO" ELSE "YES" END

       

      And a calculated field that returns the units sold when the style code in in data source 2:

      IF attr([Style Code]) = ATTR([data source 2].[Style Code]) AND (attr([data source 2].[Style Status])) = 'Active'  THEN sum([Units Sold]) END

       

      However these only work when I have the style code in the rows or columns.

       

      What I want is a roll up of the units sold when a style code appears in data source 2 and when it doesn't.

       

      I hope this is clear!

       

      Thanks