Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Pley92
Regular Visitor

How to apply a calculated slicer only on one line in a line chart?

I have the following business case: a company has begun an email marketing campaign to entice its customers to put more orders in. In order to verify if the email campaign is having an impact, customers have been divided into controls and targets: controls will not receive any emails, whereas targets will. 

 

The variable that we want to monitor over time is the average number of orders that customers have made , split (Legend) by whether they are controls or targets. For this, I have chosen a line chart.

 

Next, we want to be able to filter (Slicer) by the weekly average number of emails received by each customer: the rationale behind it is that, if the marketing campaign works and we report only those targets who have received a high average number of emails per week, the distance between the control line and the target line should increase.

 

To do that, I have created a calculated column with the following logic (please refer to the PBIX that I've linked for the DAX formula): sum of all emails received by each customer / (latest update - customer join date) * 7.

 

The problem is that, if I use this calculated column as a slicer, as soon as the lowest limit is raised from 0, the control line disappears; this is because controls, by definition, controls do not receive emails. To illustrate even better:

 

Before

Pley92_0-1683996083274.png

 

After

 

Pley92_1-1683996083280.png

 

 

 

So my question is the following: how do I create a slicer so that it only filters the target line, but not the control? The control line should remain always the same, whereas the target line should filter based on the range specified in the slicer.

Please notice that I have also included a slicer on JoinDate: this slicer should keep on working on both the control and the target lines.

 

As I've mentioned, I am linking the PBIX file (click on the link and then the Download arrow). 

 

Many thanks!

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Pley92 ,

 

According to your description, here are my steps you can follow as a solution.

(1)  My test data is the same as yours.

(2) We can create a table and a measure.

 

Table 2 = SUMMARIZE(RawData,RawData[AverageWeeklyEmails])
Measure = 
IF(
    OR(
        ISFILTERED('Table 2'[AverageWeeklyEmails]) = FALSE(),
        SELECTEDVALUE(RawData[ControlTargetStatus]) = "Control"
    ),
    AVERAGE(RawData[NoOfPurchaseOrders]),
    IF(
        SELECTEDVALUE(RawData[ControlTargetStatus]) = "Target",
        CALCULATE(
            AVERAGE(RawData[NoOfPurchaseOrders]),
            FILTER(
                RawData,
                [AverageWeeklyEmails] in VALUES('Table 2'[AverageWeeklyEmails])
            )
        )
    )
)

 

(3) Then the result is as follows.

vtangjiemsft_0-1684134992474.png

vtangjiemsft_1-1684135417136.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @Pley92 ,

 

According to your description, here are my steps you can follow as a solution.

(1)  My test data is the same as yours.

(2) We can create a table and a measure.

 

Table 2 = SUMMARIZE(RawData,RawData[AverageWeeklyEmails])
Measure = 
IF(
    OR(
        ISFILTERED('Table 2'[AverageWeeklyEmails]) = FALSE(),
        SELECTEDVALUE(RawData[ControlTargetStatus]) = "Control"
    ),
    AVERAGE(RawData[NoOfPurchaseOrders]),
    IF(
        SELECTEDVALUE(RawData[ControlTargetStatus]) = "Target",
        CALCULATE(
            AVERAGE(RawData[NoOfPurchaseOrders]),
            FILTER(
                RawData,
                [AverageWeeklyEmails] in VALUES('Table 2'[AverageWeeklyEmails])
            )
        )
    )
)

 

(3) Then the result is as follows.

vtangjiemsft_0-1684134992474.png

vtangjiemsft_1-1684135417136.png

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Thank you very much for the solution; this was exactly what I was looking for!

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.