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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Belle2015
Helper II
Helper II

Lookup to another table?

Hi, I have two tables, Table 1 has the Employee ID and Table 2 has the employee ID, expense type, value and transaction date. Some employees in table 1 may not have had an expense and be listed on table 2 for certain months or not at all. 

What I am trying to do is a matrix chart that will show all the employees listed in table 1 and give the total value and count of expenses submitted for each month that are for expense type company car and if the employee hasnt had any that it shows a zero.

Thanks in advance

Expected Output only with all employees showing and displaying  a 0 for any employees who dont have a company car expense

Belle2015_0-1744238094848.png

 

Table 1

Employee IDFuel Type Company
123456PetrolComp1
123457Diesel Comp1
123458ElectricComp1
123459Diesel Comp1
123460Diesel Comp1
123461Diesel Comp2
123462Diesel Comp2
123463ElectricComp2
123464ElectricComp1
123465ElectricComp1
123466PetrolComp1
123467ElectricComp1
123468ElectricComp1
123469PetrolComp2
123470PetrolComp2
123471Diesel Comp2
123472Diesel Comp2
123473Diesel Comp2
123474Diesel Comp2

 

Table 2

Employee IDExpense TypeTransaction DateTransaction Amount
123456Company Car12/03/20253.36
123457Car rental02/04/20253.36
123458Car rental17/03/2025111.44
123459Company Car03/04/202594.72
123460Company Car12/03/202596.08
123461Company Car02/02/202590.72
123462Company Car16/03/202585.89
123466Company Car17/03/202591.28
123467Company Car18/03/202589.95
123468Hotel19/03/202588.9
123469Public Transport20/03/20253.92
123470Company Car21/03/20253.92
123472Public Transport16/03/20253.92
123473Public Transport23/03/2025

3.92



1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Like this?

 

lbendlin_0-1744240586978.png

 

Filters should ideally come from the dimension table. Your filter (Expense type) comes from the fact table.

 

No need for a lookup, let the data model do the work for you

lbendlin_1-1744240662124.png

 

showing and displaying  a 0 for any employees who dont have a company car expense

Try not to do that, instead leave the row blank.

 

 

View solution in original post

6 REPLIES 6
v-kpoloju-msft
Community Support
Community Support

Hi @Belle2015,

May i know has your issue been resolved? If the response provided by the super users @lbendlin@danextian@Irwan, addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

Thank you for your understanding!

Irwan
Super User
Super User

hello @Belle2015 

 

i am not sure but is this what you are looking for?

Irwan_0-1744240620301.png

if yes, then you can add if statement in your expense and count measure to replace blank value into zero.

something like below

Count = 
var _Count =
CALCULATE(
    COUNT('Table 2'[Transaction Amount]),
    'Table 2'[Expense Type]="Company Car"
)
Return
IF(
    _Count=BLANK(),
    0,
    _Count
)
Expense = 
var _Expense =
CALCULATE(
    SUM('Table 2'[Transaction Amount]),
    'Table 2'[Expense Type]="Company Car"
)
Return
IF(
    _Expense=BLANK(),
    0,
    _Expense
)
Hope this will help.
Thank you.
lbendlin
Super User
Super User

Like this?

 

lbendlin_0-1744240586978.png

 

Filters should ideally come from the dimension table. Your filter (Expense type) comes from the fact table.

 

No need for a lookup, let the data model do the work for you

lbendlin_1-1744240662124.png

 

showing and displaying  a 0 for any employees who dont have a company car expense

Try not to do that, instead leave the row blank.

 

 

thank you, I got it, it was the relationship type 🙂 I was just over thinking it when it wasnt working!

Hi, This is what I was trying to do at first and had it show as blank line for the employee's without expenses until I apply the filter for company car, once I apply the filter it does not show the employee ID's without a blank like

 

danextian
Super User
Super User

Hi @Belle2015 

 

Try the following:

With Company Car Expense = 
-- This calculated column returns TRUE if the employee has a "Company Car" expense in Table2
VAR CompanyCarEmployee =
    -- Create a table of unique Employee IDs from Table2 where Expense Type is "Company Car"
    SUMMARIZE (
        FILTER ( Table2, Table2[Expense Type] = "Company Car" ),
        Table2[Employee ID]
    )
RETURN
    -- For each row in Table1, return TRUE if the Employee ID exists in the filtered list
   IF ( Table1[Employee ID] IN CompanyCarEmployee, 1, 0 )

danextian_2-1744240700459.png

 

Filter your visual to return 1 for the above calculated column or incorporate the filter in your measure.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors