Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
We have supervisors and mechanics in a table, I have written mechanics text color logic(Green,Amber,Red) based on my expression. Now I have to write a color logic on top of the supervisor based mechanic color, suppose if one supervisor under having 5 mechanics , among this five mechanics any one mechanic is having red color the supervisor name text color as red and any one mechanics is amber the supervisor text color display amber, all are green it should green. like below..
Any Help..
Hello,
I have for you an example that might help you achieve the use case scenario, however please keep in mind that this is only to help get on the right path towards the resolution, as it might not be entirely the solution.
1. I have the following dataset:
As you can see I have 4 supervisors and I have 3 mechanics under each supervisor. My logic for coloring the mechanics is the field Value and the logic is:
2. Now I have used the following expression to color my mechanics:
If(Value=1, Blue(), if(Value=2, Red(), Green()))
3. The outcome so far is:
Now based on your logic SupervisorA should appear as BLUE since it has at least 1 BLUE mechanic, SupervisorB should appear as RED since it has at least 1 RED mechanic, SupervisorC will appear BLUE, since there is at least 1 BLUE mechanic and SupervisorD should appear GREEN as all of the mechanics are GREEN.
4. Therefore, we have to implement the logic for the coloring and thus we need to find the patterns. To simplify the issue, I have the initial assumption that there are ONLY 3 mechanics under each Supervisor so I have found the following patterns:
Blue:
Conclusion:
If 3<=X<=7 there is at least 1 BLUE
Red:
Conclusion:
If 6<=X<=8 there is at least 1 RED
Green:
3 Green >> Total = 9
Conclusion:
If X=9 then all are GREEN
5. Now we know that all we have to do, is to sum all the values of the field Value for all the mechanics for each supervisor separately and then check to which range does it belong. However, this will only work under the hypothesis that there are only 3 mechanics for each supervisor, therefore we need a more scalable solution.
6. For this, I have used the following expressions:
First we need to count all the mechanics for each supervisor and the expression for that is:
CountMechanicsOfEachSupervisor = Sum(Aggr( NODISTINCT Count(Mechanic), Supervisor)
Then we need to sum all the values of all the mechanics for each supervisor and the expression for that is:
SumValuesForAllMechanicsOfParticularSupervisor = Sum(Aggr( NODISTINCT Sum(Value), Supervisor))
7. Now to make sure that the next complicated expression is simplified, I have created 3 helping variables:
8. Final step is to combine the expressions above with If() functions to see each time within which range we are. To do so I have followed the following expression:
If(
SumValuesForAllMechanicsOfParticularSupervisor >= CountMechanicsOfEachSupervisor * '$(vBlue)')
and
SumValuesForAllMechanicsOfParticularSupervisor <= (CountMechanicsOfEachSupervisor - 1) * 3 + '$(vBlue)'),
Blue(),
If(
SumValuesForAllMechanicsOfParticularSupervisor >= CountMechanicsOfEachSupervisor * '$(vRed)')
and
SumValuesForAllMechanicsOfParticularSupervisor <= (CountMechanicsOfEachSupervisor - 1) * 3 + '$(vRed)'),
Red(),
If(
SumValuesForAllMechanicsOfParticularSupervisor = CountMechanicsOfEachSupervisor * '$(vGreen)'),
Green(),
Brown()
)
)
)
You will have to replace the SumValuesForAllMechanicsOfParticularSupervisor with the actual expression and CountMechanicsOfEachSupervisor with the actual expression from above!
Allow me to explain the logic behind it:
9. The output is:
As you can see SupervisorA is BLUE because at least one mechanic is BLUE, SupervisorB is RED because at least 1 mechanic is RED, SupervisorC is BLUE because there is at least one mechanic BLUE and SupervisorD is GREEN because all the mechanics are GREEN.
In your use case scenario I would recommend to use your expressions to generate the values in Data load editor and create the additional field "Value". Because as you can see, the calculations are already complicated. So instead of coloring then your mechanics with the expression you shared, you will just do so with If(Value=1, Blue(), if(Value=2, Red(), Green())) since the values will be already calculated!
As I have mentioned above, this might not be a complete solution for your use case scenario, however it might help you get on the right path towards the resolution!
What is the logic for coloring Mech?
Hi Almen,
Thanks for your reply. Below is the mechanic text color logic..
If((aggr(Sum(Sales),Mechanic)/aggr(sum(SalesObjective),Mechanic)) >0.90,RGB(146,208,80),
If((aggr(Sum(Sales),Mechanic)/aggr(sum(SalesObjective),Mechanic))>=0.70, RGB(255,191,0),RGB(255,0,0)))
Hello,
I have for you an example that might help you achieve the use case scenario, however please keep in mind that this is only to help get on the right path towards the resolution, as it might not be entirely the solution.
1. I have the following dataset:
As you can see I have 4 supervisors and I have 3 mechanics under each supervisor. My logic for coloring the mechanics is the field Value and the logic is:
2. Now I have used the following expression to color my mechanics:
If(Value=1, Blue(), if(Value=2, Red(), Green()))
3. The outcome so far is:
Now based on your logic SupervisorA should appear as BLUE since it has at least 1 BLUE mechanic, SupervisorB should appear as RED since it has at least 1 RED mechanic, SupervisorC will appear BLUE, since there is at least 1 BLUE mechanic and SupervisorD should appear GREEN as all of the mechanics are GREEN.
4. Therefore, we have to implement the logic for the coloring and thus we need to find the patterns. To simplify the issue, I have the initial assumption that there are ONLY 3 mechanics under each Supervisor so I have found the following patterns:
Blue:
Conclusion:
If 3<=X<=7 there is at least 1 BLUE
Red:
Conclusion:
If 6<=X<=8 there is at least 1 RED
Green:
3 Green >> Total = 9
Conclusion:
If X=9 then all are GREEN
5. Now we know that all we have to do, is to sum all the values of the field Value for all the mechanics for each supervisor separately and then check to which range does it belong. However, this will only work under the hypothesis that there are only 3 mechanics for each supervisor, therefore we need a more scalable solution.
6. For this, I have used the following expressions:
First we need to count all the mechanics for each supervisor and the expression for that is:
CountMechanicsOfEachSupervisor = Sum(Aggr( NODISTINCT Count(Mechanic), Supervisor)
Then we need to sum all the values of all the mechanics for each supervisor and the expression for that is:
SumValuesForAllMechanicsOfParticularSupervisor = Sum(Aggr( NODISTINCT Sum(Value), Supervisor))
7. Now to make sure that the next complicated expression is simplified, I have created 3 helping variables:
8. Final step is to combine the expressions above with If() functions to see each time within which range we are. To do so I have followed the following expression:
If(
SumValuesForAllMechanicsOfParticularSupervisor >= CountMechanicsOfEachSupervisor * '$(vBlue)')
and
SumValuesForAllMechanicsOfParticularSupervisor <= (CountMechanicsOfEachSupervisor - 1) * 3 + '$(vBlue)'),
Blue(),
If(
SumValuesForAllMechanicsOfParticularSupervisor >= CountMechanicsOfEachSupervisor * '$(vRed)')
and
SumValuesForAllMechanicsOfParticularSupervisor <= (CountMechanicsOfEachSupervisor - 1) * 3 + '$(vRed)'),
Red(),
If(
SumValuesForAllMechanicsOfParticularSupervisor = CountMechanicsOfEachSupervisor * '$(vGreen)'),
Green(),
Brown()
)
)
)
You will have to replace the SumValuesForAllMechanicsOfParticularSupervisor with the actual expression and CountMechanicsOfEachSupervisor with the actual expression from above!
Allow me to explain the logic behind it:
9. The output is:
As you can see SupervisorA is BLUE because at least one mechanic is BLUE, SupervisorB is RED because at least 1 mechanic is RED, SupervisorC is BLUE because there is at least one mechanic BLUE and SupervisorD is GREEN because all the mechanics are GREEN.
In your use case scenario I would recommend to use your expressions to generate the values in Data load editor and create the additional field "Value". Because as you can see, the calculations are already complicated. So instead of coloring then your mechanics with the expression you shared, you will just do so with If(Value=1, Blue(), if(Value=2, Red(), Green())) since the values will be already calculated!
As I have mentioned above, this might not be a complete solution for your use case scenario, however it might help you get on the right path towards the resolution!