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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KamalMalek
New Member

Distinct Count with sum conditions

Dear All,

In table down i need to count active users with no purchase at all,

when we use Dax Furmula Measue= calculate(distinctcount{"User", Filter(status="Active"&&purcahse value="0") = 3 users which is wrong 

Exp: Rami & Ahmad reapeated multi times "Value =0 and Value >0, so should be excluded from our Measure

i need furmual with Answer =1 , because only user "Wassem" is active and never purchased 

UserstatusPurchase value
RamiActive0
AhmadActive0
fahadNot Active0
wassemActive0
RamiActive22
RamiActive33
AhmadActive50
2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@KamalMalek 

Use this measure: 

Never Bought = 
CALCULATE(
    COUNTROWS(
        FILTER(
            DISTINCT( Table10[User] ),
            CALCULATE( SUM(Table10[Purchase value]) ) = 0
        )
    ),
    

 

Fowmy_0-1705155452244.png



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

latimeria
Solution Specialist
Solution Specialist

Hi @KamalMalek ,

 

Another way:

 

VAR StatusActiveAndPurchase0 =
    DISTINCT(
        SELECTCOLUMNS(
            FILTER( 'Table', 'Table'[Purchase value] = 0 && 'Table'[Status] = "Active" ),
            "@User", 'Table'[User]
        )
    )
VAR STatusActiveAndPurchaseNot0 =
    DISTINCT(
        SELECTCOLUMNS(
            FILTER( 'Table', 'Table'[Purchase value] > 0 && 'Table'[Status] = "Active" ),
            "@User", 'Table'[User]
        )
    )
RETURN
    COUNTROWS( EXCEPT( StatusActiveAndPurchase0, STatusActiveAndPurchaseNot0 ) )

 

View solution in original post

5 REPLIES 5
Fowmy
Super User
Super User

@KamalMalek 

Use this measure: 

Never Bought = 
CALCULATE(
    COUNTROWS(
        FILTER(
            DISTINCT( Table10[User] ),
            CALCULATE( SUM(Table10[Purchase value]) ) = 0
        )
    ),
    

 

Fowmy_0-1705155452244.png



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Really appreciate your support thanks a lot 🙂

@KamalMalek 

Kinldy accept it as solution if it works for you.

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

latimeria
Solution Specialist
Solution Specialist

Hi @KamalMalek ,

 

Another way:

 

VAR StatusActiveAndPurchase0 =
    DISTINCT(
        SELECTCOLUMNS(
            FILTER( 'Table', 'Table'[Purchase value] = 0 && 'Table'[Status] = "Active" ),
            "@User", 'Table'[User]
        )
    )
VAR STatusActiveAndPurchaseNot0 =
    DISTINCT(
        SELECTCOLUMNS(
            FILTER( 'Table', 'Table'[Purchase value] > 0 && 'Table'[Status] = "Active" ),
            "@User", 'Table'[User]
        )
    )
RETURN
    COUNTROWS( EXCEPT( StatusActiveAndPurchase0, STatusActiveAndPurchaseNot0 ) )

 

Thanks a lot 🙂 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors