Forum Discussion
Line Chart: Conditional Formatting
- 7 years ago
Hi Sirlearnalot,
For your scenario, you should create the four measures below to achieve your desired output.
Yes_P1 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="Yes"&&'Table1'[Product]=1)) Yes_P2 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="Yes"&&'Table1'[Product]=2)) No_P1 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="No"&&'Table1'[Product]=1)) No_P2 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="No"&&'Table1'[Product]=2))Then you drag these measure to Values Field to create the line chart.
In addition, you could refer to this attachment.
Best Regards,
Cherry
Thank you v-piga-msft !
To explain what I mean:
I want to show Quarter on x, Sales on Y and Product as the legend, but with colour change if Campaign period says yes or no.
| Product | Sales | Quarter | Campaign period |
| 1 | 7000 | 1 | Yes |
| 1 | 5000 | 2 | No |
| 1 | 6500 | 3 | Yes |
| 1 | 4000 | 4 | No |
| 2 | 80000 | 1 | No |
| 2 | 15000 | 2 | Yes |
| 2 | 7000 | 3 | No |
| 2 | 7500 | 4 | No |
I saw the post you referred to and it's exactly the result I want, but not sure how to apply it when it's a "4th variable", maybe I can structure the data differently?
Hi Sirlearnalot,
For your scenario, you should create the four measures below to achieve your desired output.
Yes_P1 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="Yes"&&'Table1'[Product]=1))
Yes_P2 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="Yes"&&'Table1'[Product]=2))
No_P1 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="No"&&'Table1'[Product]=1))
No_P2 = CALCULATE(SELECTEDVALUE(Table1[Sales]),FILTER('Table1','Table1'[Campaign period]="No"&&'Table1'[Product]=2))
Then you drag these measure to Values Field to create the line chart.
In addition, you could refer to this attachment.
Best Regards,
Cherry
- Sirlearnalot7 years agoNew Member
Hi,
Sorry for late replay! I actually solved it in an other way and got the result I was looking for:
The dotted line is the "no campaign" and the green the campaign period during the year.
What I did was to put the values for "campaign" and "no campaign" in different columns (even though they represent total quantity for that period) and then made a measure:
TotalQuantity = SUMX('2018';'2018'[Quantity No campaign]+'2018'[Quantity Campaign])And then put TotalQuantity and Quantity Campaign as values.