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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ukozlows
Regular Visitor

Measure all rows 'grouped' in 1 column if 1 row meets a condition

Hi,

 

First time posting.

 

I am working in PowerPivot and would like help with either a dax measure or a calculated column or simply a nifty way to add a conditional column using M in PowerQuery. (the only way i know how is to add a grouping and take the max sales, then ungroup with all data - but i have a few million rows and I don't know if this will be too heavy)

 

The situation is based on the customer groups shown under Cust and their respective sales shown under Sales, I want to flag the rows as Yes if any of the sales records are >0 for a given customer (so that I can measure all the visits if any sales were made).

 

CustSalesFlagVisits
Cust10YES5
Cust110YES15
Cust20NO0
Cust20NO5
Cust35YES5
Cust310YES5
Cust315YES10
    
measure visits  
Cust1  20
Cust2  0
Cust3  20
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @ukozlows 

please try

Number of Visits :=
SUMX (
    VALUES ( 'Table'[Cust] ),
    CALCULATE ( IF ( SUM ( 'Table'[Sales] ) > 0, SUM ( 'Table'[Visits] ), 0 ) )
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @ukozlows 

please try

Number of Visits :=
SUMX (
    VALUES ( 'Table'[Cust] ),
    CALCULATE ( IF ( SUM ( 'Table'[Sales] ) > 0, SUM ( 'Table'[Visits] ), 0 ) )
)
ukozlows
Regular Visitor

Thanks for the Measure!  But I am getting a blank result.

 

Maybe it is I am lookig for the total and not by customer.  (In this example would be 40 (20+20).)

 

Here is the error message I receive:

 

ukozlows_0-1666952693544.png

 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1666951373825.png

 

Visits measure: =
IF (
    HASONEVALUE ( Data[Cust] ),
    IF ( SUM ( Data[Sales] ) <> 0, SUM ( Data[Visits] ), 0 )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.