Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
Thanks in advance,
Regards,
Chandra
Solved! Go to Solution.
@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
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thanks a lot. It has really worked very well.
@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
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
User | Count |
---|---|
57 | |
33 | |
18 | |
18 | |
15 |
User | Count |
---|---|
94 | |
86 | |
39 | |
22 | |
20 |