The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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).
Cust | Sales | Flag | Visits |
Cust1 | 0 | YES | 5 |
Cust1 | 10 | YES | 15 |
Cust2 | 0 | NO | 0 |
Cust2 | 0 | NO | 5 |
Cust3 | 5 | YES | 5 |
Cust3 | 10 | YES | 5 |
Cust3 | 15 | YES | 10 |
measure visits | |||
Cust1 | 20 | ||
Cust2 | 0 | ||
Cust3 | 20 |
Solved! Go to Solution.
Hi @ukozlows
please try
Number of Visits :=
SUMX (
VALUES ( 'Table'[Cust] ),
CALCULATE ( IF ( SUM ( 'Table'[Sales] ) > 0, SUM ( 'Table'[Visits] ), 0 ) )
)
Hi @ukozlows
please try
Number of Visits :=
SUMX (
VALUES ( 'Table'[Cust] ),
CALCULATE ( IF ( SUM ( 'Table'[Sales] ) > 0, SUM ( 'Table'[Visits] ), 0 ) )
)
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:
Hi,
Please check the below picture and the attached pbix file.
Visits measure: =
IF (
HASONEVALUE ( Data[Cust] ),
IF ( SUM ( Data[Sales] ) <> 0, SUM ( Data[Visits] ), 0 )
)
User | Count |
---|---|
15 | |
13 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
20 | |
13 | |
9 | |
7 |