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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ChandraDXB
Frequent Visitor

Identifying new and renewal lease and mapping of new customer or existing customer

 

Dear All and @Fowmy 

 

I have to calcuate measures for the following two scenarios:

 

1. If I need to add customer status as if there is a new customer first time for that specific unit , then put "New" else if same customer has renewed the contarct then "Renewal" otherwise "Vacant" as default.

2. If for same unit, how many times we have got new customer - to get this info, if there is new customer first time then 0 and for every subsequent new customers, put 1. if same customer has renewed the contarct, then put 0. 

The two scenarios have been provided in the below table.

 

Solution has been provided in below table, this solution needs to be replicated in DAX

 

ChandraDXB_0-1704129726318.png

 

Thanks in advance,

Regards,

Chandra

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@ChandraDXB 

Here is the code for both the calculated columns:

 

Customer Status = 
VAR __UnitNo = Table01[Unit No]
VAR __Customer = Table01[Customer Name]
VAR __StartDate = Table01[Start Date]
VAR __T = FILTER( Table01 , Table01[Unit No] = __UnitNo && Table01[Start Date] < __StartDate && Table01[Customer Name] = __Customer)  
VAR __Result = IF( ISEMPTY( __T) , "New" , "Renewal")
RETURN
    __Result

 

 

 

Contract Status = 
VAR __UnitNo = Table01[Unit No]
VAR __StartDate = Table01[Start Date]
VAR __Customer = Table01[Customer Name]
VAR __T = FILTER( Table01 , Table01[Unit No] = __UnitNo && Table01[Start Date] < __StartDate)  
VAR __Result = 
    SWITCH(
        TRUE(),
        ISEMPTY( __T) , 0,
        __Customer IN SELECTCOLUMNS(__T,Table01[Customer Name]), 0,
        1
    )
RETURN
    __Result

 

 

Fowmy_0-1704140465746.png

 







Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
ChandraDXB
Frequent Visitor

Thanks a lot. It has really worked very well.

Fowmy
Super User
Super User

@ChandraDXB 

Here is the code for both the calculated columns:

 

Customer Status = 
VAR __UnitNo = Table01[Unit No]
VAR __Customer = Table01[Customer Name]
VAR __StartDate = Table01[Start Date]
VAR __T = FILTER( Table01 , Table01[Unit No] = __UnitNo && Table01[Start Date] < __StartDate && Table01[Customer Name] = __Customer)  
VAR __Result = IF( ISEMPTY( __T) , "New" , "Renewal")
RETURN
    __Result

 

 

 

Contract Status = 
VAR __UnitNo = Table01[Unit No]
VAR __StartDate = Table01[Start Date]
VAR __Customer = Table01[Customer Name]
VAR __T = FILTER( Table01 , Table01[Unit No] = __UnitNo && Table01[Start Date] < __StartDate)  
VAR __Result = 
    SWITCH(
        TRUE(),
        ISEMPTY( __T) , 0,
        __Customer IN SELECTCOLUMNS(__T,Table01[Customer Name]), 0,
        1
    )
RETURN
    __Result

 

 

Fowmy_0-1704140465746.png

 







Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors