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
Anonymous
Not applicable

Look up another table with date range

Hi All,

 

The problem - 

Our sales team gets company-provided vehicles. Each month, we get an excel file that has information on the number miles of being driven by various employees in these leased vehicles.

A snippet of the merged files - 

Driver Employee IDDays ReportedOdometerPersonal MilesBusiness MilesTotal MilesDate
1111317939710857968712/1/2019
2222317298714487810221/1/2020
1111309190935041476411/1/2019
44440 0002/1/2020
55553161025297975127210/1/2019

 

I have to create a report that calculates –

  1. The projected Business miles of drivers for a year based on a certain time period. I created a measure, [Annualized Cumulative Business Miles] = DIVIDE('fleet'[M Total Business Miles] * 365,'fleet'[M Total Days Reported],0) for the same.  Note, [M Total Business Miles] and [M Total Days Reported] are also measures.
  1. A calculated column, [Compliance Status] = IF('fleet'[Annualized Cumulative Business Miles] >= 12000, "Compliant", "Not-Compliant")

Basically, we need to check if it is worth giving employees leased vehicles. If they are projected to completed 12,000 miles in a year, their [Compliance Status] is “Compliant”. Otherwise they are “Not-Compliant”.

This table is called ‘Fleet’.

First PartFirst Part

 

The issue is that there is another table – ‘Exception Drivers’ -  that has a list of drivers  who are not to be considered for the above mentioned compliance.

Employee IDException TypeStart DateExpiration Date
111111/1/20181/1/2021
222221/1/20197/1/2020

 

We are provided with a [Start Date] and an [End Date]. Anytime a driver falls within this date range, he/she should be considered as an "Exception". So now, my calc. column – [Compliance Status] - will have 3 values, i.e., "Compliant", "Non-Compliant" and "Exception".

 

Exception Table (it'll have more values filled in)Exception Table (it'll have more values filled in)

 

Thing to note – Fleet table and Exception Drivers table are linked by the Driver/Emp ID.

The mapping from ‘Fleet’ to ‘Exception Drivers’ is *:1 (Many-to-1)

 

My Question –

How do I look up the ‘Exception Driver’ table and return the class of “Exception” into the column [Compliance Status] which is part of the ‘Fleet’ Table. Also, I must keep in mind the [Start Date] and [End Date] in the ‘Exception Driver’ table.

 

Truly appreciate your patience and comments.

 

PS: I made changes after @Greg_Deckler  suggested I make it simpler for users to understand the problem. Tried to include a a few rows of data and the measures as well. Hope this helps.

2 REPLIES 2
Greg_Deckler
Super User
Super User

Well, if the data range doesn't matter:

 

VAR __Exempt = DISTINCT('Table'[Employee ID])

IF(MAX([PRSN_ID])) IN __Exempt,"Excempt", <calculation goes here>

 

If dates do matter, then I feel there is missing information that would be required to complete a suitable answer. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks for the speedy response! I've updated my question. Is there anyway you can share with me what happens if we have to consider the date range as well?

 

Best Regards

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.