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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Charli2516
New Member

If statement not totalling

Hello

 

I need some help with an IF Statement not totalling.

 

I am trying to calculate new customers and lost customers. I have a rolling 12 months calculation current year and a rolling 12 months calculation for the prior year.

 

My IF statement says 

NEW CUSTOMER CY = if(and([SALES LY 2023] = 0,[Sales CY 2024] >0), 1, 0)
 
Which works correctly - but it doesnt total up correctly.
 
The SALES LY 2023 and SALES CY 2024 are also measures.
 
Can you please help?
Thanks
Charli
7 REPLIES 7
v-linhuizh-msft
Community Support
Community Support

Hi @Charli2516 ,

 

Have you solved your problem? If it is solved, please share your solution and accept it as solution or mark the helpful replies, it will be helpful for other members of the community who have similar problems as yours to solve it faster. Thank you very much for your kind cooperation!

 

Best Regards,
Zhu

Bibiano_Geraldo
Super User
Super User

Hi @Charli2516 ,

please try the bellow measure:

 

NEW CUSTOMER CY = 
SUMX(
    VALUES(CustomerTable[CustomerID]),
    IF(
        AND(
            [SALES LY 2023] = 0,
            [Sales CY 2024] > 0
        ),
        1,
        0
    )
)

 

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

rajendraongole1
Super User
Super User

Hi @Charli2516 - You can achieve this using the SUMX function

create below measure:

 

NEW CUSTOMER CY =
SUMX(
VALUES(TableName[CustomerID]), -- Replace 'TableName[CustomerID]' with the column that uniquely identifies your customers
IF(
AND([SALES LY 2023] = 0, [SALES CY 2024] > 0),
1,
0
)
)

 

Hope the above works. please check.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





i have put the new calculation in the 'Total New Customers' Column, and as you can see this doesnt pull through the same data as the 'New Customer CY'. It does total however..?

Charli2516_0-1734010717214.png

 

Hi @Charli2516 - can you please modify and update the rows and the total, modify NEW CUSTOMER CY to use the same row-by-row logic applied in Total New Customers. 

 

NEW CUSTOMER CY =
SUMX(
VALUES('YourTable'[Customer]),
IF(AND([SALES LY 2023] = 0, [Sales CY 2024] > 0), 1, 0)
)

 

Add a table visual with detailed columns (e.g., Customer, [SALES LY 2023], [Sales CY 2024]).
Verify the row-level logic and ensure [SALES LY 2023] and [Sales CY 2024] return the expected values.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





I have already done a table to show the logic.

 

Charli2516_0-1734011443002.png

 

The New customer CY shows that they have sales in 2024 so they should be a 1 for a new customer, but the new formula you have provided doesnt show the 1 in all the customers when it should?

 

Thanks for the replies from rajendraongole1 and Bibiano_Geraldo.

 

Hi @Charli2516 ,

 

Please try the following formula:

Total New Customer= SUMX('yourtablename',[New Customer CY])

 

If the problem persists, could you please provide a link to the .pbix file with the sensitive data removed (using e.g. OneDrive, Dropbox, Google Drive), this could help to quickly find the problem!

 

Best Regards,
Zhu
Community Support Team

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.