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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
tkwh1
Frequent Visitor

show values in data table filtered under different conditions

Hello all, 

I need help with DAX code that would produce results in a matrix table under the following conditions.  So far not much luck..

 

Conditions

For example, i have the following data with items under "Inventory",  "Shipped", and "Invoiced" column.

The actual table consists of thousands of rows, and the items in "Inventory", "Shipped" are not unique.  They can consist of same/similar items.

 

The requirement

1) Filter "Invoiced" column as "No".   (this will determine the "Inventory" items)

2)  Based on the Inventory items in 1), I need all of the "Shipped" items for each Inventory item, if the "Invoiced" condition is set to "Yes".

 

*In the actual data, per each "Inventory" item, it will usually consist of 1 or more "Shipped" items.

 

 

InventoryShippedInvoiced
AZYes
BYNo
CXYes
AWNo
BVYes
CUYes
ATNo
BSYes
CRNo
AQYes

 

 

Thank you in advance! 

1 ACCEPTED SOLUTION

HI @tkwh1,

It seems like I missed the first condition to filter items which 'Invoiced' field equal to 'No' , you can try to the following measure formula if it suitable for your requirement:

Distinct Shipped Count Per Inventory =
VAR InventoryList =
    CALCULATETABLE (
        VALUES ( Table1[Inventory] ),
        FILTER ( ALLSELECTED ( Table1 ), [Invoiced] = "No" )
    )
RETURN
    CALCULATE (
        COUNTROWS ( VALUES ( Table1[Shipped] ) ),
        FILTER (
            ALLSELECTED ( Table1 ),
            [Invoiced] = "Yes"
                && [Inventory] IN InventoryList
        ),
        VALUES ( Table1[Inventory] )
    )

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @tkwh1,

You can try to use following measure formula to get Invoiced and shipped count based on inventory group:

Distinct Shipped Count Per Inventory =
CALCULATE (
    COUNTROWS ( VALUE ( Table1[Shipped] ) ),
    FILTER ( ALLSELECTED ( Table1 ), [Invoiced] = "Yes" ),
    VALUES ( Table1[Inventory] )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

hi Xiaoxin,

Thank you for your response, really appreciate the suggested code you provided.

 

I tried it and thought it had worked initially, but after checking the result, it seems that the "Inventory" items displayed included other Inventory items as well.

Using your code I tried different variations but still cannot get the exact result I need.,,

HI @tkwh1,

It seems like I missed the first condition to filter items which 'Invoiced' field equal to 'No' , you can try to the following measure formula if it suitable for your requirement:

Distinct Shipped Count Per Inventory =
VAR InventoryList =
    CALCULATETABLE (
        VALUES ( Table1[Inventory] ),
        FILTER ( ALLSELECTED ( Table1 ), [Invoiced] = "No" )
    )
RETURN
    CALCULATE (
        COUNTROWS ( VALUES ( Table1[Shipped] ) ),
        FILTER (
            ALLSELECTED ( Table1 ),
            [Invoiced] = "Yes"
                && [Inventory] IN InventoryList
        ),
        VALUES ( Table1[Inventory] )
    )

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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