Forum Discussion

ivan_larson_cki's avatar
ivan_larson_cki
Icon for Helper III rankHelper III
6 years ago

Matrix not Filtering by Higher-Level Query

I have a matrix showing various measures calculating sales for specific products. The products are listed as rows, and are broken out from categories. I have a higher-level Category query that i need for other visuals, but one of its functions is to slice this matrix. I only want to see the rows of the matrix that are relevant after applying the category slicer. How do I make this happen?

 

Current Visuals:

How it currently appears when sliced ("Hardware" and its associated rows should be hidden):

 

Categories:

CategorySales Target
Food1000
Hardware800

 

Product Data:

CategoryProduct
FoodBurger
FoodPizza
HardwareComputer
HardwareDesk
FoodMilk

Measures on Product Table:

Sales by Alpha = 0+CALCULATE(SUM(Sales[Amount]),FILTER('Sales','Sales'[Sales Person]="Alpha"))
Sales by Beta = 0+CALCULATE(SUM(Sales[Amount]),FILTER('Sales','Sales'[Sales Person]="Beta"))
Sales by Gamma = 0+CALCULATE(SUM(Sales[Amount]),FILTER('Sales','Sales'[Sales Person]="Gamma"))
Sales by Delta = 0+CALCULATE(SUM(Sales[Amount]),FILTER('Sales','Sales'[Sales Person]="Delta"))
Sales Total = 0+CALCULATE(SUM(Sales[Amount]))

 

Sales Data:

ProductAmountSales Person
Burger20Alpha
Pizza40Alpha
Computer60Alpha
Desk50Alpha
Milk70Beta
Burger70Beta
Pizza30Beta
Computer80Beta
Desk60Gamma
Milk30Gamma
Burger50Gamma
Pizza40Gamma
Computer60Delta
Desk30Delta
Milk70Delta

9 Replies

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi ivan_larson_cki 

        If [Category] in the slicer is from 'Categories' table? try to use 'Categories'[Category] to create a slicer and try it again.

        If you still have the problem, could you please share your sample pbix file for us have a test, there should be something wrong in other.

        You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

         

        Regards,

        Lin

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion

    ivan_larson_ckithis is the direction of your table

     

     

    which means the expanded table in DAX does

    left outer with

    categories to products

    and

    Categories-Products does left outer with Sales

     

    Bring Category from category table and Product from Product Table in the matrix

    For slicer bring category from Category table it should be able to slice

    • ivan_larson_cki's avatar
      ivan_larson_cki
      Icon for Helper III rankHelper III

      Hi smpa01,

       

      Thank you for your suggestion. In your matrices, food products are listed under hardware, and hardware products are listed under food. Is there a way to prevent that in the structure you're suggesting?

      • smpa01's avatar
        smpa01
        Icon for Community Champion rankCommunity Champion

        Please change  to

        Sales by Alpha = CALCULATE(SUM(Sales[Amount]),FILTER('Sales','Sales'[Sales Person]="Alpha"))
        or
        use
        Alpha = CALCULATE(SUMX(Sales,Sales[Amount]),FILTER(Sales,Sales[Sales Person]="Alpha"))