BASE DE CONNAISSANCES

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


Date de publication : 01 Mar 2024
Date de dernière modification : 04 Mar 2024

Problème

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

Environnement

  • Tableau Desktop

Résolution

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

 

Cause

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)
Cet article vous a-t-il permis de résoudre le problème ?