KNOWLEDGE BASE

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


Veröffentlicht: 01 Mar 2024
Zuletzt geändert am: 04 Mar 2024

Problem

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

Umgebung

  • Tableau Desktop

Lösung

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

 

Ursache

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)
Hat dieser Artikel das Problem gelöst?