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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerUser123
Helper II
Helper II

Measure to Sum Customers with No Sales in Selected Period?

My source data has customer name and transaction date that I have linked to a traditional calendar table. 

 

We are looking at this data by quarter.

 

I have a filter to select a quarter. I want a measure that looks at the prior year quarter and sums all the customers who had sales in that quarter but not the selected quarter.

 

So I have Q2 2022 selected. I want a measure that sums the sales amount from Q2 2021 for all the customers who had sales in Q2 2021 but no sales in Q2 2022. This is my attempt but it's not really working:

 

No Sales Reported in Selected Qtr = CALCULATE([Prior Year QTD $],FILTER(VALUES('Combined Data'[Customer]),'Combined Data'[Net Sales $]=BLANK()))
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @PowerUser123 
Please try

No Sales Reported in Selected Qtr =
VAR CurrentYear =
    YEAR ( MAX ( 'Date'[Date] ) )
VAR CurrentYearCustomers =
    VALUES ( 'Combined Data'[Customer] )
VAR CurrentYearCustomers =
    CALCULATETABLE (
        VALUES ( 'Combined Data'[Customer] ),
        'Date'[Year] = CurrentYear - 1
    )
VAR ChurnedCustomers =
    EXCEPT ( CurrentYearCustomers, CurrentYearCustomers )
RETURN
    CALCULATE ( [Prior Year QTD $], ChurnedCustomers )

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1662219694302.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tamerj1
Super User
Super User

Hi @PowerUser123 
Please try

No Sales Reported in Selected Qtr =
VAR CurrentYear =
    YEAR ( MAX ( 'Date'[Date] ) )
VAR CurrentYearCustomers =
    VALUES ( 'Combined Data'[Customer] )
VAR CurrentYearCustomers =
    CALCULATETABLE (
        VALUES ( 'Combined Data'[Customer] ),
        'Date'[Year] = CurrentYear - 1
    )
VAR ChurnedCustomers =
    EXCEPT ( CurrentYearCustomers, CurrentYearCustomers )
RETURN
    CALCULATE ( [Prior Year QTD $], ChurnedCustomers )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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