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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MP-iCONN
Resolver I
Resolver I

Matrix Table Filter issue

My scenario is I have a matrix table that consists of a the following rows:

 

Work Order ID | Parent Item IDComponent Item IDRequired Date 

 

Then some other Values but the most import value is a Calculated Column called Available Comp which is how much of the Component Item ID we have in stock to put toward building the Parent Item ID.  What I need to do is if the Available Comp is a negative value then mark that Work Order ID as SHORT, but if we have enough of the Availabe Comp and it is positive then mark as OK.

 

The table data would look somthing like this.  Then the expected behavior would be a slicer to filter on SHORT or OK and from the table below WO12345 would be SHORT because it has one negative value and the other WO22345 would be OK.   Because it is a matrix table is why I am struggling to figure out how to make that custom column to mark the work order as SHORT or OK

 

Work Order IDParent Item IDComponent Item IDRequired DateAvailable Comp
WO12345P1212C121212/31/20225
  C121312/31/202210
  C121412/31/2022-5
  C121512/31/20226
  C121612/31/20221
WO22345P2134C22221/15/2023100
  C22231/15/202350
  C22241/15/202311
  C22251/15/202310

 

Any advice would be greatly appreciated!

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@MP-iCONN,

 

Try this calculated column, which can be used as a matrix filter:

 

Work Order Status = 
VAR vWorkOrderID = Table1[Work Order ID]
VAR vNegativeRows =
    FILTER (
        Table1,
        Table1[Work Order ID] = vWorkOrderID
            && Table1[Available Comp] < 0
    )
VAR vResult =
    IF ( ISEMPTY ( vNegativeRows ), "OK", "SHORT" )
RETURN
    vResult

 

DataInsights_0-1670783466550.png

 





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

Proud to be a Super User!




View solution in original post

v-xinruzhu-msft
Community Support
Community Support

Hi @MP-iCONN 

You can create a new column:

Column = VAR A=FILTER('Table','Table'[Work Order]=EARLIER('Table'[Work Order])&&'Table'[Available]<0)
RETURN IF(COUNTAX(A,[Work Order])>0,"Short","Ok")

vxinruzhumsft_0-1670825806693.png

Best Regards,

Yolo Zhu

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

6 REPLIES 6
v-xinruzhu-msft
Community Support
Community Support

Hi @MP-iCONN 

You can create a new column:

Column = VAR A=FILTER('Table','Table'[Work Order]=EARLIER('Table'[Work Order])&&'Table'[Available]<0)
RETURN IF(COUNTAX(A,[Work Order])>0,"Short","Ok")

vxinruzhumsft_0-1670825806693.png

Best Regards,

Yolo Zhu

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

Actually I was able to do a merge queries in Power Query on both of those tables and once I made all the necessary columns I was then able to use this DAX that you gave and it worked out great.  Thank you very much!

These look like great solutions but I believe I should have mentioned the work order ID and Available Comp are in two different tables.  They are related tables but related by Many to many with Both direction by the Parent ID in both tables.  Getting the available comp in these DAX is proving difficult because you can't use RELATED() with the many to many relationship.

Vilmar
Resolver I
Resolver I

Veja se o anexo aqui ajuda.

 

Vou explicar:

  • Esta é a receita para produzir o item P1212;

Sem título1.png

 

  • O item P1212 tem pedido para dezembro (115 unidades) e janeiro (170 unidades);
  • De todos seu componentes, só tem estoque para produzir em dezembro, pois o componente C1214 não vai ter saldo suficiente:
    • Estoque: 1300
    • Total dos pedidos: 10 x (115 + 170) = 2850

 

Sem título.png

DataInsights
Super User
Super User

@MP-iCONN,

 

Try this calculated column, which can be used as a matrix filter:

 

Work Order Status = 
VAR vWorkOrderID = Table1[Work Order ID]
VAR vNegativeRows =
    FILTER (
        Table1,
        Table1[Work Order ID] = vWorkOrderID
            && Table1[Available Comp] < 0
    )
VAR vResult =
    IF ( ISEMPTY ( vNegativeRows ), "OK", "SHORT" )
RETURN
    vResult

 

DataInsights_0-1670783466550.png

 





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

Proud to be a Super User!




I tested with your DAX code as well @DataInsights and it also worked.  Thank you very much to both you and @v-xinruzhu-msft !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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