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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nierodzt
Frequent Visitor

Combining a Calendar with Date Driven Data

Hello,

 

New user to the Power B.I Community. I was wondering if I could get some help on a problem.

 

I work for a rental company and the goal is to combine calendar dates with dates vehicles are rented to determine which days the company did not rent any vehicles.

 

I have two tables. The first, contains the days vehicles are rented with location and other business data (Column A contains vehicle number, B contains the date, C the location, ETC). There are over 900 vehicles with multiple days rented for each.  The second table is a list of all the days of 2017.

 

Is there anyway I can merge or combine the data so that each day in 2017 has it own vehicle associated with it? Example, since 100114 was not used on 09/16/2017, 09/17/2017, 09/21/2017, and 09/23/2017-10/09/2017 I would like to see a blank space associated with those dates.

 

 

Vehicle InformationVehicle Information        Dates of 2017Dates of 2017

 

8 REPLIES 8
v-xjiin-msft
Solution Sage
Solution Sage

Hi @nierodzt,

 

In your scenario, you want to show corresponding rented vehicle information of each day in 2017. Right?

 

To achieve your requirement, I think you just need to create a relationship for your two tables (Vehicle Information and Calendar table), then put the date column of Calendar table and the vehicle information into one same table visual. Please refer:

 

111.PNG

 

Thanks,
Xi Jin.

 

 

dramus
Continued Contributor
Continued Contributor

Do you need to know which vehicles were not rented, or just the number that were not rented on a particular day?

 

 

 

I would have to know the vehicle that was not rented

dramus
Continued Contributor
Continued Contributor

Yuck. How many vehicles are we talking about? Creating a column for each would seem to not be a viable solution. Which was my first thought.
dramus
Continued Contributor
Continued Contributor

Take a look at the DAX function NATURALLEFTOUTERJOIN().

 

I created the following table, which I think gives you what you want.

 

All Dates and Vehicles = NATURALLEFTOUTERJOIN('calendar','Vehicle Information')

 

There needs to be a link between the Calendar and Vehicle Information tables, so that the function knows  what to join on.

dramus
Continued Contributor
Continued Contributor

Hmm....Just added a second Equipment ID and found that it's not working exactly as needed. 

 

I'll keep working on it.

dramus
Continued Contributor
Continued Contributor

I have it working. I had to jump through a couple of hoops.

 

First I created a table with just the Equipment ID's in it.

 

I then used the CROSSJOIN() function to create a cartesian product table of the dates and the equipment.

All Dates And Equipment = CROSSJOIN('calendar','Equipment')

I then added a column to the "All Dates and Equipment" table:

Was Rented = if(isblank(LOOKUPVALUE('Vehicle Information'[Charge Date],'Vehicle Information'[Charge Date],[Date],'Vehicle Information'[Equipment Id],[Equipment])),"No","Yes")

I think this gives you what you need.

 

Rentals.PNG

 

PM me with your email address if you would like the PBIX file.

Close to 900 😞

 

I will give it a try. thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.