KNOWLEDGE BASE

Unexpected Values Are Displayed When Setting Color on a Bar Chart Displaying Multiple Measures


Pubblicato: 01 Mar 2024
Data dell'ultima modifica: 04 Mar 2024

Problema

Unexpected values are displayed when setting Color on a bar chart displaying multiple measures.

For example, assume that you have the following data.

 User-added image

when each measure is calculated as follows, 0 is displayed on each bar after setting Color.

 Field Name: Male
 Formula: COUNT(IF [Gender] = "Male" THEN [ID] END)

 Field Name: Female
 Formula: COUNT(IF [Gender] = "Female" THEN [ID] END)

 User-added image

Ambiente

  • Tableau Desktop

Soluzione

In this case, use SUM instead of COUNT. When aggregating NULLs with SUM function, Tableau Desktop returns NULLs. 
Follow along in the sample packaged workbook found in the Attachments section to compare the difference.

 Field Name: Male (SUM)
 Formula: SUM(IF [Gender] = "Male" THEN 1 END)

 Field Name: Female (SUM)
 Formula: SUM(IF [Gender] = "Female" THEN 1 END)

 User-added image

 

Causa

In the following formula, data records that do not match the IF condition will be NULLs. When counting NULLs, Tableau Desktop returns 0.

 Formula: COUNT(IF [Gender] = "Male" THEN [ID] END)
Con questo articolo hai risolto il problema?