6 Replies Latest reply on Jun 19, 2019 1:06 PM by Edward Ostrovsky

    Color data based on group granularity

    Edward Ostrovsky

      For the attached, I am trying to have the data colored at the granularity chosen in the row.

      So if it is at Tool Name granularity on the row, then color should be at Tool Name, not Tool Type.

      Note that my actual data has more than 5 granularity levels. Thank you

        • 1. Re: Color data based on group granularity
          Michel Caissie

          Edward,

           

          Assuming that every time you display an extra dimension of the hierarchy, new rows are added to the view.

          And assuming you have an idea on the number of rows the view will contain at each level of the hierarchy,

          you can compute the size() of the view (nb of rows)  and based on the result select to dimension to be used for the color.

           

          In your example, you could use a calculation

          if size() <= 4 then ATTR( [Tool Type] )

          elseif size() > 4   and size() <=  7 then ATTR( [Tool Name]  )

          end

          compute using table down

           

          In your real scenario, you may not have the precise values of each dimension size but you may be able to guess the boundaries

          and return the dimension if the result is between those boundaries.

           

          Michel

          1 of 1 people found this helpful
          • 2. Re: Color data based on group granularity
            Edward Ostrovsky

            Michael Casey, what if I have a date dimension in the rows after Tool Type/ Tool Name?

            How can I use size() then, since the length of the date dimension increases every day or so... Thank you

            • 3. Re: Color data based on group granularity
              Michel Caissie

              Edward,

               

              Just add a    elseif size() >  X then  ATTR(Date)      where  X  is the maximum possible number of Tool Type/Tool Name groups.

               

              The challenge does not come from the date dimension but from the  estimation of the number of   Tool Type-Tool Name  combination.

               

              Let say that when  Tool Name is Exploded, you have 100 rows. If each tools have an avg of 2 dates, then the size() would be 200 when date is exploded.

              So if you put  150  for X,  you could still add 50 tools  and the solution would still work.

              But again , this is not a perfect solution,  it implies some guessing ,  and may need some adjustments in time  according to the dataset growth.

               

              ps: my name is Michel Caissie,   Michael Casey  is another person.

              • 4. Re: Color data based on group granularity
                Edward Ostrovsky

                Michel Caissie apologies about the name confusion.

                I don't think I explained correctly since I tried adding the condition you mentioned with date but then it colors at the date level, which isn't what I need.

                Attached workbook for reference.

                As you can see, when Tool Name is expanded, it colors properly- since there are two tool names and two colors.

                However, when it is at the Tool Type level, it doesn't color in one color (since there is just 1 tool type A), since size() doesn't work properly since it becomes the size of the activity dates..

                Thank you in advance

                • 5. Re: Color data based on group granularity
                  Michel Caissie

                  Well this is different.

                   

                  You can try to compute the number of date per Tool Type,  sum those dates  and compare it with the size()

                  Color would become

                  if size()<= MIN( [Day per Tool Type] )then ATTR( [Tool Type] )

                  else ATTR( [Tool Name]  )

                  end

                   

                  where Day per Tool Type is

                  {SUM({FIXED [Tool Type]: COUNTD( DATETRUNC('day', [Activity Date] ) )})}