Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I have the following data:
Index all | Channel | Index By Sensor | SensorNum | Value |
0 | Detector_1 | 0 | Sensor_1 | 18 |
1 | Detector_1 | 1 | Sensor_1 | 97 |
2 | Detector_1 | 2 | Sensor_1 | 17 |
3 | Detector_1 | 3 | Sensor_1 | 14 |
4 | Detector_1 | 4 | Sensor_1 | 67 |
5 | Detector_1 | 0 | Sensor_2 | 54 |
6 | Detector_1 | 1 | Sensor_2 | 3 |
7 | Detector_1 | 2 | Sensor_2 | 43 |
8 | Detector_1 | 3 | Sensor_2 | 36 |
9 | Detector_1 | 4 | Sensor_2 | 0 |
10 | Detector_1 | 0 | Sensor_3 | 57 |
11 | Detector_1 | 1 | Sensor_3 | 46 |
12 | Detector_1 | 2 | Sensor_3 | 6 |
13 | Detector_1 | 3 | Sensor_3 | 36 |
14 | Detector_1 | 4 | Sensor_3 | 5 |
0 | Detector_2 | 0 | Sensor_1 | 11 |
1 | Detector_2 | 1 | Sensor_1 | 46 |
2 | Detector_2 | 2 | Sensor_1 | 51 |
3 | Detector_2 | 3 | Sensor_1 | 96 |
4 | Detector_2 | 4 | Sensor_1 | 51 |
5 | Detector_2 | 0 | Sensor_2 | 38 |
6 | Detector_2 | 1 | Sensor_2 | 80 |
7 | Detector_2 | 2 | Sensor_2 | 14 |
8 | Detector_2 | 3 | Sensor_2 | 50 |
9 | Detector_2 | 4 | Sensor_2 | 52 |
10 | Detector_2 | 0 | Sensor_3 | 33 |
11 | Detector_2 | 1 | Sensor_3 | 9 |
12 | Detector_2 | 2 | Sensor_3 | 59 |
13 | Detector_2 | 3 | Sensor_3 | 89 |
14 | Detector_2 | 4 | Sensor_3 | 17 |
The data above is dummy data and will not result in the same graph below. I will plot a line graph that filter by channel and also filter by SensorNum. In my graph below, the x axis an Index By Sensor and y axis is a measure based on the Value column and legend is SensorNum.
My goal is to change the color of the lines based on which group they belong to. For exmaple lines for Sensor1&2&3 will be all in blue (any color as long as it's the same color) and Sensors 4&5 will be in red and so on.
What could be the way to acheive this? Thank you.
Solved! Go to Solution.
Hi @Anonymous ,
This is a complex question because you cannot have legend and more than one measure with conditional formatting.
Believe that the solution goes by adding a new table with the combination of sensors and groups something similar to this:
Now add the following measure:
Values Sensor Group = CALCULATE(SUM('Readings'[Value]), 'Readings'[Group] in VALUES('Sensor_Group'[Group]) && 'Readings'[SensorNum] in VALUES('Sensor_Group'[SensorNum]), VALUES('Readings'[Group]))
Now do you chart with the following format:
X-Axis: Index By Sensor
Y-Axis: Values Sensor (measure created previously)
Legend: GroupSensor (column from the new table)
Now manually change the color for each group, and probably add the series label:
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Anonymous ,
If you have a group that allows you to have the sensor aggregated create a measure similar to this one:
Color values =
SWITCH(SELECTEDVALUE(Table[Group]),
"Group 1", "Blue",
"Group 2", "Green",
"Group 3", "Yellow",
...
"Group N", "Red")
Then use this measure to colour your lines condittionaly
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThank you for your reply. Do you mean I should be using the measure as a legend? Can you provide an example please?
Hi @Anonymous ,
Sorry for missleading you, since you have a legend this is not as direct as I referenced, I apologize.
If you are using the Sensor as legend then you aren't abble to have different colour per group since the context of each line will be based on the value of the sensor so if you have sensor 1 for two groups whitin the line chart the value consider is only of the sensor not of the sensor + group.
Confirm if I'm correct you want to have for example
Sensor 1 (Group1)- Blue
Sensor 1 (Group2) - Green
However the Group is not a part of your chart directly?
How many sensors do you have and are they going to change, meaning increase the number of sensors?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHey @MFelix , thank you. No need for an apology. So I can add the grouping, meaning I can add a table that says to which group each sensor belong instead of the filters if that would makes it easiter to solve.
Sensor 1 | Group 1 |
Sensor 2 | Group 1 |
Sensor 3 | Group 2 |
My goal now will be to make lines of the sensors of the same group to have the same color in the graph, so sensor 1& 2 will be red and sensor 2 will be yellow.
To answer you question, yes sensor numbers could vary.
Hi @Anonymous ,
This is a complex question because you cannot have legend and more than one measure with conditional formatting.
Believe that the solution goes by adding a new table with the combination of sensors and groups something similar to this:
Now add the following measure:
Values Sensor Group = CALCULATE(SUM('Readings'[Value]), 'Readings'[Group] in VALUES('Sensor_Group'[Group]) && 'Readings'[SensorNum] in VALUES('Sensor_Group'[SensorNum]), VALUES('Readings'[Group]))
Now do you chart with the following format:
X-Axis: Index By Sensor
Y-Axis: Values Sensor (measure created previously)
Legend: GroupSensor (column from the new table)
Now manually change the color for each group, and probably add the series label:
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsUser | Count |
---|---|
84 | |
77 | |
76 | |
43 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
45 | |
43 |