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
Anupam
Frequent Visitor

Create Mesuare the get the visit id based on entry and exit date

HI ,

I have three tables visit data, contain details of customer visit with entry and exit date. A date table (contain all dates) and a customer date with customer date (id and name). I want a table where I can get for each date and each customer the city in which  customer was residing on the given date. 

 

For date and customer table, I have done cross join, but I am not able to create a measure to get the visit id corresponding to date and customer value. PFA the demo pbix file. 
https://drive.google.com/file/d/11gnlxWPg9hpYtBZr5bPJJd4ZeZWZSkc-/view?usp=sharing

3 REPLIES 3
DataNinja777
Super User
Super User

Hi @Anupam,

 

I downloaded your file and noted that in the file a relationship was created between the transaction ID in the fact table 'VisitData' and the customer ID in the customer dimension table, so I changed that relationship to be between customer ID and customer # in the 'VisitData', as I thought you meant to create that relationship instead. 

 

The resultant relationship in the data model looks like below:

Sakiko_0-1694424324616.png

 

Then, I created a measures like below to identify the trip locations and ID visited by customers at a given date.

Sakiko_1-1694424456150.png

 

Sakiko_2-1694424587781.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I've then combined these measures in a table measure like below. As you can see, when the customer ID #1 travels from Indore to Mumbai on May 1, 2023, both travel ID #1 and #11 apear on the row of that date with two location names.  

Sakiko_3-1694424723387.png

I attach the pbix file below:

Travel location ID.pbix

 

ERD
Community Champion
Community Champion

Hi, a measure might be

 

VisitID =
VAR selected_date = MAX ( Customer_date[Date] )
VAR customerid = MAX ( Customer_date[id] )
RETURN
    CALCULATE (
        MAX ( VisitData[City] ),
        VisitData[Customer] = customerid,
        VisitData[Entry Date] <= selected_date,
        VisitData[Exit Date] > selected_date
    )

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

nirali_arora
Resolver II
Resolver II

This problem seems similar to the HR Analytics problem which has start date and end date.

You can follow the video and find your solution.

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4 
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
Power BI: HR Active Employee Tenure Bucketing, and Hired, Terminated, and Active employees: https://youtu.be/fvgcx8QLqZU

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.