Forum Discussion
Schmidtmayer
Helper II
6 years agoCalculating Coefficient of Variation
Hello everyone 😃 I do have a table containing the following columns: Personal Number, Date, Team, Project, TimeCategory, Time There are multiple Personal Numbers per Team, multiple Teams pe...
- Anonymous6 years ago
All filtering is one-way only from a dimension to the fact table.
// Dimensions: // Employee connected to FactTable[PIN] (1:*) // Calendar connected to FactTable[Date] (1:*) // Team connected to FactTable[TeamId] (1:*) // Project connected to FactTable[ProjectId] (1:*) // TimeCategory connected to FactTable[TimeCategoryId] (1:*) // All *Id fields are hidden in dimensions. // // All columns in the FactTable must be hidden. // Only measures can be visible. All slicing is // done through dimensions. This is the correct // star schema model. // Define the following measures. They work for any // slice for any dimension. In particular for // slices on Employee. [Total] = SUM( FactTable[Hours] ) [Illness] = CALCULATE( [Total], KEEPFILTERS( TimeCategory[TimeCategoryId] = "Illness" ) ) [IllnessQuota] = DIVIDE( [Illness], [Total] ) [Proportion To Team] = var __totalForEmps = [Total] var __teamsOfEmps = summarize( FactTable, Team[TeamId] ) var __totalForTeams = calculate( [Total], __teamsOfEmps, all( Employee ), all( Team ) ) var __result = divide( __totalForEmps, __totalForTeams ) return __result [VC for Team] = var __oneTeamVisible = hasonevalue( Team[TeamId] ) var __team = SUMMARIZE( FactTable, Team[TeamId] ) var __employees = SUMMARIZE( FactTable, Employee[PIN] ) var __numerator = SQRT( SUMX( __employees, var __iqForEmp = [IllnessQuota] var __iqForTeam = calculate( [IllnessQuota], __team, all( Team ), all( Employee ) ) var __propToTeam = [Proportion To Team] var __result = __propToTeam * POWER( __iqForEmp - __iqForTeam, 2 ) return __result ) ) var __denominator = calculate( [IllnessQuota], __team, all( Team ), all( Employee ) ) var __varCoeff = DIVIDE( __numerator, __denominator ) return if( __oneTeamVisible, __varCoeff )Once you've implemented the correct model, please let me know how it goes. Thanks 🙂
Best
D
Schmidtmayer
Helper II
6 years agoAnonymous:
Thanks for pointing out. I was aware of this during testing of my measure. All the values were complete garbage the first time I tried it. That's why I used the second table for the values of the whole group I am looking at and crossjoining it. Til now, everything works fine. Also checked the values via pocket calculator.
Regaring the DataModell: Sorry for ignoring it. We are using this model as a standard within our departement, so I didn't answer this.
Greetings Tom
Anonymous
6 years agoNot applicable
Hi there.
Just the last word of warning: If you have a model that consists of one big fact table, then you'll never know when the problem with auto-exist will bite you because it's almost random (it's not really but whether it happens or not depends on data distribution in your table).
So, in a word, you are risking producing wrong numbers without even knowing it. If you and your department can live with that... then all is good.
Best
D
Just the last word of warning: If you have a model that consists of one big fact table, then you'll never know when the problem with auto-exist will bite you because it's almost random (it's not really but whether it happens or not depends on data distribution in your table).
So, in a word, you are risking producing wrong numbers without even knowing it. If you and your department can live with that... then all is good.
Best
D