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
Anonymous
Not applicable

count if for a measure

I have a visual like this:

Dateconvert_number
Dec5
Jan22
Feb12

convert_number is a measure that counts customers based on conditions

 

I have two other measures that calculates the average sales before event, and the average sales  after.

 

I would like to count how many customers of convert_number have increased average sales.

 

e.g. countif(sales after - sales before) > 0

 

Obviously this doesn't work, I tried using count and countA but they need tables, could someone come up with a solution so my visual would be like this:

Dateconvert_numberincreased sales
Dec53
Jan2217
Feb129

 

Thanks a lot!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@Anonymous 
Try this code

increased sale =
VAR T1 =
    SUMMARIZE ( ALL ( 'Orders' ), 'Date'[Date] )
VAR T2 =
    ADDCOLUMNS (
        T1,
        "@Count", [convert_number],
        "@SalesBefore", [Sales Before],
        "@SalesAfter", [Sales After]
    )
VAR T3 =
    FILTER ( T2, [@SalesAfter] > [@SalesBefore] )
RETURN
    SUMX ( T3, [@Count] )

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

@Anonymous 
Try this code

increased sale =
VAR T1 =
    SUMMARIZE ( ALL ( 'Orders' ), 'Date'[Date] )
VAR T2 =
    ADDCOLUMNS (
        T1,
        "@Count", [convert_number],
        "@SalesBefore", [Sales Before],
        "@SalesAfter", [Sales After]
    )
VAR T3 =
    FILTER ( T2, [@SalesAfter] > [@SalesBefore] )
RETURN
    SUMX ( T3, [@Count] )
tamerj1
Super User
Super User

Hi @Anonymous 
What are the tables invloved? Do you have a Date table? you are slicing by Month right? From which table? 
However, you may try somthing like this

increased sale =
SUMX ( VALUES ( 'Date'[Date] ), IF ( [Sales After] > [Sales Before], 1 ) )
Anonymous
Not applicable

Thank you for the response!

 

Only the order table is involved. I have a date table. I am slicing it by month from the date table. 

 

I tried the solution but it returns a static number that's the same for every month.

Hi, @Anonymous 

Could you please tell me whether your problem has been solved?

If yes, you could accept the helpful answer as solution.

If you still need help, please share a sample file for further research

Best Regards,
Community Support Team _ Eason

Noted

can you please provide the code of the three Measures?

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.