Forum Discussion

matt_campbell's avatar
matt_campbell
Regular Visitor
1 year ago
Solved

Measures with Sum in Matrix Rows

Hi all -

I have a Matrix visual showing inventory liquidation data. The rows come from a pre-aggregated fact table. Filtering works fine for 1:1 relationships (stocked month to inventory), but breaks when I add dimensions like Inventory Types or Departments to the row-level fact table. How can I properly filter on these dimensions without breaking the matrix relationships? Here is a sample of the Row fact table:

 

Stocked MonthInventory StockedRemaining Inventory
1/31/2021631752663
2/28/2021567272306
3/31/2021777923234


Here is a sample of the Columns and Values table:

 

IDSold DateSold Date FormattedLast_Date_Of_Month
11/21/20212021-11/31/2021
22/5/20212021-21/31/2021
371/14/20212021-11/31/2021
1031/15/20212021-11/31/2021
1321/15/20212021-11/31/2021
1661/15/20212021-11/31/2021
891/19/20212021-11/31/2021
1231/19/20212021-11/31/2021
1631/19/20212021-11/31/2021
1751/19/20212021-11/31/2021
1841/19/20212021-11/31/2021
121/20/20212021-11/31/2021
1181/20/20212021-11/31/2021
1701/20/20212021-11/31/2021
71/21/20212021-11/31/2021
182/9/20212021-22/28/2021
302/9/20212021-22/28/2021
1472/9/20212021-22/28/2021
863/16/20212021-33/31/2021

 

Here is a sample of the current output. I only want to filter on dimensions. I do not need to display them.

 

  • v-dineshya's avatar
    v-dineshya
    1 year ago

    Hi matt_campbell ,

    Please find attached snap and PBIX file.

    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.

     

6 Replies

  • TzuChiao26's avatar
    TzuChiao26
    Frequent Visitor

    How is your pre-aggregated fact table linked to row-level fact table?
    Also, could you explain how the matrix visual works (how each cell is calculated)? That might help others figure out how to build the solution.

    • matt_campbell's avatar
      matt_campbell
      Regular Visitor

      Thank you for the reply. The tables are linked by Last_Date_Of_Month. I have updated the original post which I left out that column. The matrix cells are the Count Sold divided by Inventory Stocked for the row. The cells can also show Count. Here is a view of count. 

       

       

       

  • v-dineshya's avatar
    v-dineshya
    Community Support

    Hi matt_campbell ,

    Thank you for reaching out to the Microsoft Community Forum.

     

    You are expecting to filter properly without displaying those dimensions in the visual.

    Please follow below steps.

    1. Created 3 tables, InventoryType, InventoryFact and Department with sample data.

    2. Created Measure "Inventory Stocked Filtered" with below DAX.

    Inventory Stocked Filtered =
    CALCULATE(
    SUM('InventoryFact'[Inventory Stocked]),
    TREATAS(VALUES(InventoryType[Inventory Type]),InventoryFact[Inventory Type]),
    TREATAS(VALUES('Department'[Department]), 'InventoryFact'[Department])
    )

    3. Created Measure "Remaining Inventory Filtered" with below DAX.

    Remaining Inventory Filtered =
    CALCULATE(
    SUM('InventoryFact'[Remaining Inventory]),
    TREATAS(VALUES('InventoryType'[Inventory Type]), InventoryFact[Inventory Type]),
    TREATAS(VALUES(Department[Department]),InventoryFact[Department])
    )

    4. In Matrix visual, Drag 'InventoryFact'[Stocked Month] in Rows, Inventory Stocked Filtered and Remaining Inventory Filtered measures in Values and
    InventoryType[Inventory Type] and 'Department'[Department] in slicers.

    5. Please refer output snap and attached PBIX file for your reference.

     

    If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
    Thank you.

    • matt_campbell's avatar
      matt_campbell
      Regular Visitor

      This does not accomplish setting multiple rows. I need each row to be Stocked Month, Stocked Inventory, Inventory Remaining. The columns should be Sold Month. Values are Count of Sold. I've attached an updated example. 

       

      • v-dineshya's avatar
        v-dineshya
        Community Support

        Hi matt_campbell ,

        Please find attached snap and PBIX file.

        If this information is helpful, please “Accept it as a solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
        Thank you.