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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
quikin5
Frequent Visitor

Matrix row totals not working properly

Hi, I have a matrix with year, month (both from a calendar table), and customer as row headers. As for values I have the following measure: 

Lost Customers Amount =
VAR currentCustomers = VALUES(SALES[Customer])
VAR previousMonthDates = PREVIOUSMONTH('DATE'[Date])
VAR previousMonthCustomers = CALCULATETABLE(SALES[Customer]),ALL('DATE'[Date]), previousMonthDates)
VAR LostCustomers= EXCEPT(previousMonthCustomers,currentCustomers)
VAR LastMonthAmount = CALCULATE(SUM(SALES[Sales]), DATEADD('DATE'[Date], -1, MONTH), LostCustomers)
RETURN
    SUMX(LostCustomers, LastMonthAmount)

The measure returns the sales of the customers who purchased the previous month but did not purchase the selected month.

The measure works fine in the matrix at customer level, but fails to aggregate the sum properly at month level.

Any idea would be very appreciated! 
2 REPLIES 2
amitchandak
Super User
Super User

@quikin5 ,

 

In such case create a new measure ,

 

Sumx(Values(VALUES(SALES[Customer]), [Lost Customers Amount])

 

Also check my approach of just using isblank and avoid expcept

 

Customer Retention with Dynamic Segmentation, New/Lost/Retain Customer Count: https://youtu.be/EyL7KMw877Q

 

Customer Retention Part 1:
https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-1-Month-on-Month-Retention/b...
Customer Retention Part 2: Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retenti...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

It didn't work 😞

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors