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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
zhangb94
Regular Visitor

Filtering multiple row data with DAX?

Hello Experts!

 

I hope you're able to help me out here... I am relatively new to Power BI and DAX but will try my best to explain.

 

I am trying to determine the amount of Users either by a calculcated column via DAX with the following logic or through another method (am open to feedback and suggestions):

 

  • If user purchased any amount of items (items purchased) via Method B, and has atleast one item purchased via Method A, this should count as "0".
  • If user purchased 7 or more items (items purchased) via Method B ONLY, this counts as 1 user. 

 

RegionUserMethod of PurchaseItems Purchased
ONBobA2
ONBobA2
ONBobA2
ONBobB7

 

I've created a table via DAX using SUMMARIZE, and created a calculcated column using DAX to formulate:

 

 

 

COLUMN =
var _value =
IF (AND(
TableName[MethodOfPurchase] = "A", TableName[ItemsPurchased] > 7), 0,
IF (AND(TableName[MethodOfPurchase] = "B", TableName[ItemsPurchased] >=7), 1, BLANK())
)
RETURN _value

 

 

 

which results in "1" when it should be "0". 
 
RegionUserMethod of PurchaseItems PurchasedColumn
ONJohnA2 
ONJohnB81

 

Feedback is always welcome and am open to learning!
 
Thank you all!
1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
Community Support

Hi @zhangb94 ,

According to your description, here is my solution.

Since the sample data you gave does not match the expected output you wanted, I create a new sample based on your description.

vxiaosunmsft_0-1662532478740.png

Create a column.

Column =
IF (
    COUNTROWS (
        FILTER (
            'Table',
            'Table'[User] = EARLIER ( 'Table'[User] )
                && [Method of Purchase] = "A"
        )
    ) > 0
        && COUNTROWS (
            FILTER (
                'Table',
                'Table'[User] = EARLIER ( 'Table'[User] )
                    && [Method of Purchase] = "B"
            )
        ) > 0,
    0,
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[User] = EARLIER ( 'Table'[User] )
                    && [Method of Purchase] = "B"
                    && [Items Purchased] >= 7
            )
        ) > 0,
        1
    )
)

Final output:

vxiaosunmsft_1-1662532525882.png

 

Best Regards,
Community Support Team _ xiaosun

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
v-xiaosun-msft
Community Support
Community Support

Hi @zhangb94 ,

According to your description, here is my solution.

Since the sample data you gave does not match the expected output you wanted, I create a new sample based on your description.

vxiaosunmsft_0-1662532478740.png

Create a column.

Column =
IF (
    COUNTROWS (
        FILTER (
            'Table',
            'Table'[User] = EARLIER ( 'Table'[User] )
                && [Method of Purchase] = "A"
        )
    ) > 0
        && COUNTROWS (
            FILTER (
                'Table',
                'Table'[User] = EARLIER ( 'Table'[User] )
                    && [Method of Purchase] = "B"
            )
        ) > 0,
    0,
    IF (
        COUNTROWS (
            FILTER (
                'Table',
                'Table'[User] = EARLIER ( 'Table'[User] )
                    && [Method of Purchase] = "B"
                    && [Items Purchased] >= 7
            )
        ) > 0,
        1
    )
)

Final output:

vxiaosunmsft_1-1662532525882.png

 

Best Regards,
Community Support Team _ xiaosun

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

 

lbendlin
Super User
Super User

your sample data does not match the expected output. Please check.

Thanks for your response. Updated DAX:

 

 

 

COLUMN =
var _value =
IF (AND(
TableName[MethodOfPurchase] = "A", TableName[ItemsPurchased] < 7), 0,
IF (AND(TableName[MethodOfPurchase] = "B", TableName[ItemsPurchased] >=7), 1, BLANK())
)
RETURN _value

 

 

 

SHOULD yield the results in "COLUMN"

 

RegionUserMethodOfPurchaseItemsPurchasedColumn
ONBobA20
ONBobA20
ONBobA20
ONBobB71

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.