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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Filtering Table rows by earliest date

Hi all,

A relative new DAX user here - so a simple topic I am sure.

I have created a table (Services Table) which shows the start date of every service that our customers have. I have created a 2nd related table (Cust Table) using Summarise to show whether the first service each customer has is a Mobile or not.  Here are the two fomulaes I have used so far in the Cust Table:

 
1: Cust Table = SUMMARIZE('Services Table','Services Table'[CustID])
This is working to create the customer ID collum.
 
2: Service ID = LOOKUPVALUE('Services Table'[serviceid],'Services Table'[CustID],'Cust Table'[CustID],1)

This almost works, but of course every time there are multiple start dates for a customer it is populating with my test value of "1".

I have been trying to use a range of formula approaches such as first date, filters, calculate to select the right service based on date, but I'm not sharing them because none of them are working, and I may be on totally the wrong path. Please see below the tables I am trying to see (using dummy data).

 

Any clues for me please team of legends?  

 

Rangi28_1-1683683713801.png

 

Rangi28.

 

 

3 REPLIES 3
Anonymous
Not applicable

(Circular Dependancy is sorted out - ignore that please)

FreemanZ
Super User
Super User

hi @Anonymous 

try like:

1) create a calculated table like:

Customer = 
ADDCOLUMNS(
    VALUES(Service[CustID]),
    "ServiceID",
    CALCULATE( MIN(Service[ServiceID])),
    "Date",
    CALCULATE( MIN(Service[Date]))
)

2) join service and customer table on the ServiceID column

3) add a calculated column in Service table like:

Type = IF(RELATED(Service[Type])<>"Mobile", "Others", "Mobile")

it worked like:

FreemanZ_0-1683687058860.png

Anonymous
Not applicable

Almost legendary thankyou  @FreemanZ , I've run it on a real data set and the customer table mostly pulls exactly what I want, the exception is where a mobile and an "other" service have the same start date, and it is the earliest date (for a given customer). DAX has to pick one sevice ID over the other, and I'm not sure of its logic. Can we force it to pick Mobile within the Cust table code when there is a choice to be made?

 

My other challenge is creating the relationship between the cust table and the services table, Im getting a Circular Dependnecy alert - which is very surprising and probably something seperate for me to trouble shoot.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.