Skip to main content

Hi all,

 

I am not sure how to handle following the best way in tableau:

 

  1. I have a set of data with attributes
  2. for certain attributes I'm looking if some values for a specific attribute is present and if so than 1 else 0
  3. for the set of selected attributes (around 6) I need to make a lookup calculation based on weights per attribute:
  4. for example for data line 1 my atrtibute 1 = 1, attribute 2=0, attribute 3=1 where I have my lookup table that says that teh weight for attribute 1=2, weight attribute 2=1; weight attribute 3=1.5 so it would give for my first data line a total of 3.5 and then color code it

I'm quite unsure how to do this in tableau. Currently we do this in excel and paste in every 2 days new data, but I want to automate it in Tableau.

 

Thanks for any idea or guidance on this

3 个回答
  1. 2022年9月26日 10:19

    @Inneke Beirnaert​ Hi Inneke

    It would be easier if there was an attached workbook, but based on how I understood your question, there are 2 ways I can think of, which you can try in your work.

     

    Method 1

    If in your Excel data source, these attributes are running across the cells, then I would suggest that these are pivoted so that the attributes and the associated values run down vertically.

    @Inneke Beirnaert​ Hi InnekeIt would be easier if there was an attached workbook, but based on how I understood your question, there are 2 ways I can think of, which you can try in your work.Once pivoted, the table should look like the below image.

    Image 02 

    Then it is simply a case of creating a new calculated field to state the conditions such as

     

    if [Attribute Types]='Attribute 1' then [Attribute Value]*(Weight)

    elseif [Attribute Types]='Attribute 2' then [Attribute Value]*(Weight) and so on.

     

    Then once this calculated field is completed, there is now a column that contains the calculations of the values based on the weightings applicable to each of the Attribute Types. Then it is a matter of using these calculated values to produce the final set of measures in the shape and form desired.

     

    Method 2

    Another way to achieve this would be to have two data sources where the original data source will be the same as that from Method and the secondary data source will be a look up table containing the weightings for each individual Attributes.

    Image 03 

    In Method 2, we are still required to pivot the first data source (if the attributes are running across. If they are already running vertically then pivot is not required). This means, the secondary data source can be associated with the first data source by blending.

     

    Connect to both the data sources as separate data sources. Connect to one Excel data source and then click on this arrow button next to the data source name on the Data Source tab.

    Image 04Then when a new Tableau Desktop connection window is displayed, simply perform the same steps to connect to the secondary Excel data source.

     

    Select the Original Data Source once again by using that same arrow button. Then repeat the pivot performed in Method 1.

     

    Once the pivot is done, then open a worksheet and bring in all the 3 columns from the Original Data Source, which comprises of the [Dimension], [Attribute Types] and [Attribute Value]. Once this is completed, the cross tab in the worksheet should show as follows.

    Image 05 

    Then follow these instructions.

    Image 06By performing these steps, we are creating a data relationship between the two data sources and it defines a common field through which the two data sources can relate.

     

    Once all of these steps are performed, then we could go back to the worksheet and bring in the fields from the Secondary Data Source (Look up table).

    Image 07As we can see from this updated table, we have the Attribute values and the individual weightings that are applicable to each respective Attributes these measures are associated with.

     

    From this point on, we can simply perform arithmetic such as [Attribute Value]*[Weighting] to generate a new column with the weighted points.

     

    I have attached a sample workbook for your reference.

     

    Give it a go first and if you run into issues, please let me know.