Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Dynamically calculated categories /labels in a pie chart / donut chart

Hello all,  I have beeen struggling to build a visual for quite a time now and didn't find any solutions :

 

I want to classify the locations according to certain criteria (the time period selected/  consumption over that time frame... ).

And build a pie chart/ donut chart that display the Number of locations by the different categories.

 

This is a simplified version of my data structure :

I succeeded in doing that with a static classification (a one that doesn’t depend on the time period selected) :

This is done in the “Location” table in the “Category_static“ a pre-calculated column.

Location(#) is just a simple count of the locationid.

However, I wasn’t able to create a dynamic calculated columns that varies according to the slicer selections.

-I created a measure instead to classify the location (“Category_dynamic”) . It can’t however be put in the “Legend” field for this visual (since it is not a column and it doesn’t know which level of aggregation to have to do the classification)

-I tried to make a measure for each category that compute directly the percentage in one formula  as follow :

Measure = COUNTROWS(

FILTER(ADDCOLUMNS(ADDCOLUMNS(location,

"Feature2",[Feature2],

"Feature3",[Feature3),

"STATUS",

IF(

  AVERAGE(location[Feature1])=0,

  "Cat1",

  IF(

      location[Feature1]<[Feature2],

      "Cat2",

      IF(

          location[Feature1]<[Feature3],

          "Cat2",

         IF(

             location[Feature1]-[Feature3]<0.05,

          "Cat3",

             "Cat4"

         )

      )

  )

)),[STATUS]="Cat4"))

It worked but there are no interaction with other visuals,ie for instance if I select the "Cat4" in this visuals, the locations in other visuals won't be filtered.

 

Thanks a lot,