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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Db111
Frequent Visitor

Problem with filter context

I have created a test scenario (pbix attached) where you choose a salesperson from a slicer and then see their sales, what should be a decreasing RemainingSalesTarget (in my case it creates new rows and doesn't respect the slicer selection but I had something similar working in another report). 

 

I've also created a disconnected table matrix which is meant to show a status summary for the salesperson (trying to do the sort of thing that was easy in paginated reports and using the visual to help with the formatting). But if I click on the various visuals the values change e.g. for Sally RemainingSalesTarget is 9k if I select the current status summary visual and 12k if I select the sales visual.

So issues:

a) why isn't the running sum working in this case

b) why isn't AllSelected in the RemainingSalesTarget respecting the slicer selection

c) how to stop the values changing between visuals

Many thanks for any insights

 

Test scenario.pbix

 

1 ACCEPTED SOLUTION

Thanks for the reply from audreygerred , please allow me to provide another insight:

Hi, @Db111 
 

1.Thank you for visiting the Microsoft Fabric Community Forum. We are pleased to hear that changing the filter direction has resolved many issues for you. When you set the relationship to single-direction filtering, it means that other tables cannot filter the SalesTargets table. Therefore, all rows from other tables will display corresponding output values, rather than only the matching rows.

As shown in the image below:

vlinyulumsft_0-1738821747511.png

Thus, your solution is very effective.

 

2.Additionally, the reason you see repeated values when you change the InitialTarget value to 18,000 (a fixed value) is that the LOOKUPVALUE function typically returns blank when it does not find a corresponding value. Blank values are normally aggregated in visual objects, which is why you see the duplicates disappear. However, when you output a fixed value, the parts that should output blank and aggregate will now display the fixed value.

Below is the relevant documentation:

Work with aggregates (sum, average, and so on) in Power BI - Power BI | Microsoft Learn

 

3.If you wish to change to a fixed value, you can modify the measure as follows:

RemainingSalesTarget = 
VAR InitialTarget =lOOKUPVALUE('SalesTargets'[Target], 'SalesTargets'[SalesPerson], 'SalesTargets'[SelectedSalesPerson])
VAR RunningTotalSales = 
    CALCULATE(
        SUM(Sales[SalesAmount]),
        FILTER(
            ALLSELECTED(Sales),
            Sales[Date] <= MAX(Sales[Date])
        )
    )
RETURN IF(NOT(ISBLANK(MAX('Sales'[SalesAmount]))),InitialTarget - RunningTotalSales,BLANK())

Here's my final result, which I hope meets your requirements.

 

vlinyulumsft_1-1738821791316.png

 

Please find the attached pbix relevant to the case.


Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

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

3 REPLIES 3
audreygerred
Super User
Super User

Hi! For part C you can change the interaction between visuals: Change how visuals interact in a report - Power BI | Microsoft Learn





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thanks, that fixed issue C. 

If I change the many to one relationship betwen sales and sales targets cross filter direction from single to both, the duplicate rows are removed. But if I change the VAR InitialTarget = 18000 in the method below the duplicates reappear.
Any other thoughts please.

RemainingSalesTarget =
VAR InitialTarget = LOOKUPVALUE('SalesTargets'[Target], 'SalesTargets'[SalesPerson], 'SalesTargets'[SelectedSalesPerson])
VAR RunningTotalSales =
    CALCULATE(
        SUM(Sales[SalesAmount]),
        FILTER(
            ALLSELECTED(Sales),
            Sales[Date] <= MAX(Sales[Date])
        )
    )
RETURN
    InitialTarget - RunningTotalSales

Thanks for the reply from audreygerred , please allow me to provide another insight:

Hi, @Db111 
 

1.Thank you for visiting the Microsoft Fabric Community Forum. We are pleased to hear that changing the filter direction has resolved many issues for you. When you set the relationship to single-direction filtering, it means that other tables cannot filter the SalesTargets table. Therefore, all rows from other tables will display corresponding output values, rather than only the matching rows.

As shown in the image below:

vlinyulumsft_0-1738821747511.png

Thus, your solution is very effective.

 

2.Additionally, the reason you see repeated values when you change the InitialTarget value to 18,000 (a fixed value) is that the LOOKUPVALUE function typically returns blank when it does not find a corresponding value. Blank values are normally aggregated in visual objects, which is why you see the duplicates disappear. However, when you output a fixed value, the parts that should output blank and aggregate will now display the fixed value.

Below is the relevant documentation:

Work with aggregates (sum, average, and so on) in Power BI - Power BI | Microsoft Learn

 

3.If you wish to change to a fixed value, you can modify the measure as follows:

RemainingSalesTarget = 
VAR InitialTarget =lOOKUPVALUE('SalesTargets'[Target], 'SalesTargets'[SalesPerson], 'SalesTargets'[SelectedSalesPerson])
VAR RunningTotalSales = 
    CALCULATE(
        SUM(Sales[SalesAmount]),
        FILTER(
            ALLSELECTED(Sales),
            Sales[Date] <= MAX(Sales[Date])
        )
    )
RETURN IF(NOT(ISBLANK(MAX('Sales'[SalesAmount]))),InitialTarget - RunningTotalSales,BLANK())

Here's my final result, which I hope meets your requirements.

 

vlinyulumsft_1-1738821791316.png

 

Please find the attached pbix relevant to the case.


Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

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

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors