cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

If function with distinct count

Hi,

 

I have a database as below and need to populate my client status as new or old. A client is considered as new if the 'date' and 'live date' are same. For rows 2 and 3, client is same however it has a new deal marked as -002.  client 12303 is counted twice for data source B. I need to populate the second row as blank as it has already be counted once in row 2.

 

Client Status =  IF('Table1'[Date] ='Table1'[Live_Date] , "New", )

 

How do i use distinct count?

 

Apologies for too many complications.

 

Data sourcedateLive_dateDeal IDClient IDStatus I am gettingREQUIRED STATUS
A26-Oct01-SepA00034A00034oldold
B15-Oct15-Oct012302-00112302newnew
B26-Oct26-Oct012302-00212302newold
A01-Sep01-sep102538-001102538newnew
A26-Oct26-oct102538-002102538

new

old
B26-Oct01-Sep0928abc-010928abcoldold
B26-Oct01-Sep0928abc-020928abcoldold
A01-Sep01-Sep1856XYZ541856XYZ54newnew

 

1 ACCEPTED SOLUTION

Accepted Solutions
Stachu Super Contributor
Super Contributor

Re: If function with distinct count

assuming the deals are done in chronogical order you could then rephrase the logic to

for a given customer, if the Table1[date] is equal to the the Table1[Live_date] of the first deal made for that customer then new

which corresponds to this code

Status =
VAR CurrentCustomer = Table1[Client ID]
VAR CurrentDate = Table1[Live_date]
VAR FirstDealDate =
CALCULATE (
MIN ( Table1[Live_date] ),
FILTER ( Table1, Table1[Client ID] = CurrentCustomer )
)
RETURN
IF ( Table1[date] = FirstDealDate, "new", "old" )

which gives your expected output

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

2 REPLIES 2
Stachu Super Contributor
Super Contributor

Re: If function with distinct count

assuming the deals are done in chronogical order you could then rephrase the logic to

for a given customer, if the Table1[date] is equal to the the Table1[Live_date] of the first deal made for that customer then new

which corresponds to this code

Status =
VAR CurrentCustomer = Table1[Client ID]
VAR CurrentDate = Table1[Live_date]
VAR FirstDealDate =
CALCULATE (
MIN ( Table1[Live_date] ),
FILTER ( Table1, Table1[Client ID] = CurrentCustomer )
)
RETURN
IF ( Table1[date] = FirstDealDate, "new", "old" )

which gives your expected output

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Anonymous
Not applicable

Re: If function with distinct count

Hi @Stachu,

 

thanks. That helped!! 

Helpful resources

Announcements
GregDeckler

How to Get Your Question Answered Quickly

Power BI Super User, Greg Deckler, explains

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Users Online
Currently online: 39 members 1,151 guests
Please welcome our newest community members: