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! Request now

Reply
Anonymous
Not applicable

Measure for new clients based on the year filter

Hello!

 

I have a table with clients and their respective contracts, each client can be a new client or a recurrent one. A new client is someone who had his/her contract for the first time - referent to the selected year in the year filter, for example: selecting the year "2022" on the filter, we have the contract(s) of the client X, who didn't have any other contracts prior to 2022, therefore he is a new client; however, if I select "2023" or higher, and he has another contract that year, he is not a new client anymore because he already had one in 2022, then he is a recurrent client. My question is: how can I make a measure to filter between new/recurrent clients? I need to distinguish how many clients and the total value of the contracts in each year, for both categories.

 

Thanks in advance!

 

GabrielBrito_0-1706643155811.png

GabrielBrito_1-1706643388683.png

 

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous 

 

Maybe you can try this:

First of all, I create a set of sample:

vzhengdxumsft_0-1706680946797.png

Then I create a measure:

type = 
VAR _currentyear = YEAR(MAX('Table'[Date]))
VAR _currentname = SELECTEDVALUE('Table'[name])
VAR _previousname = CALCULATE(
                        MAX('Table'[Date]),
                        FILTER(
                            ALL('Table'),
                            YEAR('Table'[Date])<_currentyear
                            &&
                            'Table'[name]=_currentname
                            )
                        )
RETURN IF(
        ISBLANK(_previousname),
        "NEW",
        "RECURRENT"
        )

The result is as follow:

vzhengdxumsft_1-1706681088222.png

 

Best Regards,

Zhengdong Xu

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

Anonymous
Not applicable

Hi @Anonymous ! Thanks for the help. The version that I'm using is older, so the SELECTEDVALUE function does not exist. Is it possible to make an alternative function? Additionally, the date and name fields are from separate tables, how can I change the FILTER function to that? 

talespin
Solution Sage
Solution Sage

hi @Anonymous ,

 

I am using adventureworks to simulate your scenario.

New or recurring customers

 

Measure

------------------

MNewOrRecurrent =
VAR _Year = SELECTEDVALUE(DimDate[CalendarYear])
VAR _ordersPriorYears = CALCULATE(COUNT(FactInternetSales[CustomerKey]), REMOVEFILTERS(DimDate[CalendarYear]), DimDate[CalendarYear] < _Year)

RETURN IF( ISBLANK([MSalesAmount]), BLANK(), IF( _ordersPriorYears > 0, "Recurring", "New") )
 
talespin_0-1706676199663.pngtalespin_1-1706676213209.png

 

 

Anonymous
Not applicable

Hi @talespin, thanks for the help! However, I'm using an older version of Power BI, so the SELECTEDVALUE and REMOVEFILTERS fuctions doesn't exist. Having said that, is it possible to make an alternative DAX?

hi @Anonymous ,

 

Sorry not aware of alternative to SELECTEDVALUE to read slicers.

Greg_Deckler
Community Champion
Community Champion

@Anonymous See if this helps: Better Sales from New Customers - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

Users online (7,391)