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
davidi4524
Helper III
Helper III

how to calculate between two columns from diffrent tables?

hi, i have two tables , one is a branch table wichh includ the branch name and profit target.

and another table wich inculde branche and total profit.

i whant to create a colum tahat make a "branch profit targer - total profit.

 

for example: cranch number one - the profit target is 1500

and the total profit is 2100

 

i whant to to 2100 - 1500 = 600

 

so the colum will show "600".

thanks for respondes.

david.

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

Medeling tab => New Table

 

Summary Table =
SUMMARIZE (
    'TotalProfit',
    'TotalProfit'[Branch Name],
    'TotalProfit'[Date],
    "Profit", CALCULATE ( SUM ( TotalProfit[Profit] ) ),
    "Target", LOOKUPVALUE (
        'Targets'[Target],
        'Targets'[Branch Name], 'TotalProfit'[Branch Name],
        'Targets'[Date], 'TotalProfit'[Date]
    )
)

 then in this new Summary Table create a column

Column = 'Summary Table'[Profit] - 'Summary Table'[Target]

 

Related Profit Final.png

View solution in original post

16 REPLIES 16
Sean
Community Champion
Community Champion

Create a Column in your 'Another Table' (I've assumed the 2 tables are related by Branch)

 

Over/Under = 'Another Table'[Total Profit] - RELATED('Branch Table'[Profit Target])

Related Profit.png

 

Hope this helps! Smiley Happy

hi, i get this error:

 

A single value for column 'totalprof' in table 'totalprofit' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

 

what to do?

Sean
Community Champion
Community Champion

The above is a Column formula you are creating a Measure that's why you are getting that error.

 

select the Table you want the column to be created in - click New Column and then enter the formula

 

Related Profit2.png

its not working for me 😞

now this error:

The column 'target[target]' either doesn't exist or doesn't have a relationship to any table available in the current context.

 

please help me

Sean
Community Champion
Community Champion

Are the 2 tables related?

 

Related Profit3.png

 

 

 

they have a relationship thru another table but they are no related. should i try to related them?

its imposible to related them because non of this table have a uniqe value. they have a relationship only thru branches table.

 

its must be a direct relationship?

Sean
Community Champion
Community Champion

Okay then forget about the relationship Smiley Happy

 

Create this Profit Target COLUMN in your 'Another Table'

 

Profit Target COLUMN = 
CALCULATE (
    LOOKUPVALUE (
        'Branch Table'[Profit Target],
        'Branch Table'[Branch Name], VALUES ( 'Another Table'[Branch] )
    )
)

Related Profit4.png

 

Then you just subtract the 2 columns Smiley Happy

 

Over/Under = 'Another Table'[Total Profit] - 'Another Table'[Profit Target COLUMN] 

Related Profit5.png

 

Hope this helps! Smiley Happy

didnt work for me. attach a pictureunnamed.png

Sean
Community Champion
Community Champion

Medeling tab => New Table

 

Summary Table =
SUMMARIZE (
    'TotalProfit',
    'TotalProfit'[Branch Name],
    'TotalProfit'[Date],
    "Profit", CALCULATE ( SUM ( TotalProfit[Profit] ) ),
    "Target", LOOKUPVALUE (
        'Targets'[Target],
        'Targets'[Branch Name], 'TotalProfit'[Branch Name],
        'Targets'[Date], 'TotalProfit'[Date]
    )
)

 then in this new Summary Table create a column

Column = 'Summary Table'[Profit] - 'Summary Table'[Target]

 

Related Profit Final.png

tanks you !! its work for me 🙂 thanks for this great solution.

 

hi, when i tried to calculate this in a tables with more than one ling' i got this error: "A table of multiple values was supplied where a single value was expected."

 

there is a snapshotpbi screen shot.PNG

please help me with this. thanks.

hi, when i tried to calculate this in a tables with more than one ling' i got this error: "A table of multiple values was supplied where a single value was expected."

 

there is a snapshotpbi screen shot.PNG

please help me with this. thanks.

How about making a combined table.  You can do this in the Query Editor as well as in DAX.

 

If you post more detail about your table structure, we can probably provide clearer step by step instructions.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

ok its go like this:

 

table 1 - named "brances" - contain the brances names

table 2 named "total profit" and contain the branch name , the month, and the total profit for month

table 3 named "targets" contain the branch name , the month ' and the target.

 

there is a relationship between "brances" and "total profit" with the colum "branch name"

and there is a relationship between "targets" and "brances" with the colum "branch name"

 

so if i choose a brach from the "branche" table' i got the numbers of the target and the total profit ok.

 

not i just whant to creatr a colum that will make the callculate between total profit - target.

 

thank you vry much for your help.

 

Hi @davidi4524,

 

Do you have relationships setup between the two tables?  So this is a direct relationship, not one that passes through another table.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.