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
QuantusPools
Frequent Visitor

Customer had sales last year but not this year.

 

 

 

=VAR CurrentYear = YEAR(MAX('Sales'[Completion Date]))
VAR LastYear = CurrentYear - 1
RETURN
IF(
CALCULATE(
COUNTROWS('Sales'),
FILTER(
'Sales',
YEAR('Sales'[Completion Date]) = LastYear
)
) > 0
&&
CALCULATE(
COUNTROWS('Sales'),
FILTER(
'Sales',
YEAR('Sales'[Completion Date]) = CurrentYear
)
) = 0,
1,
0
)

 

 

Customer NameCompletion Date

Customer 1

1/13/2022
Customer 17/25/2023
Customer 15/11/2023
Customer 15/25/2023
Customer 16/8/2023
Customer 15/20/2022

Customer 2

 

5/9/2022
Customer 25/16/2022
Customer 26/13/2022
Customer 27/9/2022
Customer 28/8/2022
Customer 29/6/2022
Customer 210/1/2022


This formula just returns 0 as if I have no lost customers.  It should be

 

1 = Made purchase in 2022 / no purchase 2023

otherwise = 0

 

Any help?

 

 

1 ACCEPTED SOLUTION
gmsamborn
Super User
Super User

Hi @QuantusPools 

Try changing your first variable to:

 

VAR CurrentYear =
    YEAR(
        MAXX( 
            ALL( 'Sales'),
            [Completion Date] 
        )
    )

 

View solution in original post

2 REPLIES 2
QuantusPools
Frequent Visitor

It worked.  Thanks so much.

gmsamborn
Super User
Super User

Hi @QuantusPools 

Try changing your first variable to:

 

VAR CurrentYear =
    YEAR(
        MAXX( 
            ALL( 'Sales'),
            [Completion Date] 
        )
    )

 

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.