Grouping

As a final check, Pam wants to make sure that the %Utilization values roll-up by Division.

To do this, follow these steps:

  1. Select a blank area of the canvas and then, from the Hours table, select Division. This creates a new table with the different divisions listed, such as 1001 Technology, 2001 Accounting, and so on.
  2. With this Table visual selected, add %Utilization to the Values for this table. Again, it is easy to see that there is some kind of issue. %Utilization for each Division is either 100% or 0%, and the Total is 100%. Worse, now that we are looking closer, when we don't have any EmployeeType selected in our slicer, the total in our original employee table visualization is also 100%, which is also not correct. Clearly, we have introduced the measure totals problem into our %Utilization measure as a result of the change we made to the #TotalHours measure.
  3. A change to our %Utilization measure is required:
%Utilization = 
VAR __utilization = DIVIDE([#TotalBillableHours],[#TotalHours],0)
VAR __days = COUNTROWS('Hours')
RETURN
IF(ISINSCOPE(People[Name]),
IF(
ISBLANK(__days),
BLANK(),
IF(
ISBLANK(__utilization),
0 ,
__utilization
)
),
VAR __tempTable =
SUMMARIZE(
'People',
'People'[Name],
"__billableHours",[#TotalBillableHours],
"__totalHours",[#TotalHours]
)
VAR __totalBillableHours = SUMX(__tempTable,[__billableHours])
VAR __totalTotalHours = SUMX(__tempTable,[__totalHours])
RETURN
DIVIDE(__totalBillableHours,__totalTotalHours,0)
)

In the preceding formula for %Utilization, we have taken the last iteration of our %Utilization measure and added the measure totals problem logic to return the correct aggregated value whenever our visualization does not display data based on individual employee rows.

In this case, we have added an IF statement to our RETURN block that uses ISINSCOPE instead of HASONEVALUE for 'People'[Name]. ISINSCOPE is a fairly new function and was specifically designed to aid in measure calculations for instances of matrix hierarchies, as well as the measure totals problem. The ISINSCOPE function returns TRUE when the specified column is the current level in a hierarchy of levels. Hence, 'People'[Name] is not in scope for Total lines within table and matrix visuals but is in scope for the individual rows of our table visualization that list %Utilization by employee.

If 'People'[Name] is in scope, then we calculate our %Utilization entries as before. If not, we create a table using SUMMARIZE and assign this to a variable called __tempTable. This table contains a summary of our table by employee Name and calculates the values of #TotalBillableHours and #TotalHours for each row in this table, assigning these values to columns named __billableHours and __totalHours, respectively. We then use SUMX to calculate the sum of both the __billableHours and __totalHours columns within this table and assign the result to the __totalBillableHours and __totalTotalHours variables. Finally, we return the value from dividing __totalBillableHours and __totalTotalHours

  1. With this change made to our %Utilization measure and by looking at both table visualizations, we can see that the Total lines now agree with one another and that we have correct %Utilization results by Division as well as by employee!
As demonstrated in the final calculation for %Utilization, VAR/RETURN pairs can be nested infinitely—well, as close to infinitely as you will likely ever need.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.209.57