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
Phil-osophy
Helper I
Helper I

Matching transactions across multiple tables

Hi  everyone,

 

ive come across an issue in my dataset that i need help solving. i have 4 different tables:

-travel extract

-intermediary file

-traveler ID number

-traveller card expenses file

 

travel extract is linked to intermediary file through a many-to-many relationship between traveler names

 

intemediary file is linked to traveler ID  number through a one-to-many relationship between the user IDs

 

traveller ID number is linked to traveler card expenses file through a one-to-many relationship between employee ID

 

what i am trying to do is verify whether the transactions that are in the travel card expenses file took place within the authorized travel dates (listed as trip date from and trip date to) in the travel extract file.

I've come up with a formula that verifies whether transactions took place between two dates however i am not sure how to link it to the specific travellers (at the moment it is not).

 

here is the formula i have:

transaction in status = IF('traveller card expenses file'[Transaction Date] < MAX('travel extract for PBI forum'[Trip Date From]) && 'traveller card expenses file'[Transaction Date < MAX('travel extract for PBI forum'[Trip Date To]),"In travel status", "Not in travel status").

 

all 4 files are accessible using the following link in addition to a screenshot of the relationships between the tables:

https://drive.google.com/drive/folders/1ar4Xp2dwNy2qrZz1EQl18-qnVgeZp2RB?usp=sharing

 

Any help greatly appreciated!

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi,

Enter this formula there

=if(ISNUMBER(CALCULATE(COUNTROWS(travel),FILTER(travel,travel[trip date from]<=EARLIER(card_expenses[Transaction Date])&&travel[trip date to]>=EARLIER(card_expenses[Transaction Date])&&travel[Traveller ID]=EARLIER(card_expenses[Employee id])))),"Travel status","Not in travel status")

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

Here's the result i got without building any relationships.  Download the Excel file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur,

 

i dont believe that is the correct excel file link as i dont see any formula included. it seems to be the same excel files i shared.

Hi,

Go to PowerPivot > Manage.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

thank you!

 

do you know if there is any way to output something similar to what i had in my formula (if the expense took place during travel dates, the output is '' travel status'', otherwise if it took place outside of travel dates the output is ''not in travel status'')?

Hi,

Enter this formula there

=if(ISNUMBER(CALCULATE(COUNTROWS(travel),FILTER(travel,travel[trip date from]<=EARLIER(card_expenses[Transaction Date])&&travel[trip date to]>=EARLIER(card_expenses[Transaction Date])&&travel[Traveller ID]=EARLIER(card_expenses[Employee id])))),"Travel status","Not in travel status")

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur!

 

i'm just curious as to how the last part of the if statement works:

 

travel[Traveller ID]=EARLIER(card_expenses[Employee id])

 

what does ''EARLIER'' do in the context of the traveller ID? i understand how it would apply to the trip date from and trip date to but unsure in this context.

Hi,

In simple Engligh that statement says that the ID's in that column should be equal to the ID of the current row.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you @Ashish_Mathur !

 

Would you know how to create a formula that would work with the relationships seeing as that is what i have in my actual power BI file because my dataset is significantly larger than what i shared?

 

thanks!

Hi,

My formula should work even if you build relationships between the tables.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.