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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
ash_cool10
Frequent Visitor

Creating a measure using two different column from different table

Hi There,

 

I am trying to create a calculated measure where i am taking difference from two columns(one is calculated measure and one is calculated column) which is avaiable in two different tables and they have Many to Many relationship .

 

ProductTable A (Amount in Rs)Table B (Amount in Rs) Difference
Bag100400300
Bat200100-100

 

 

Desrire Result i am looking for is column name "Difference"

 

Can anyone help me how to achieve this ??

 

Thanks ,

Ashish

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi  @ash_cool10 ,

Refer the below:

sumtablea = CALCULATE(SUM(TableA[value]),ALLEXCEPT(TableA,TableA[Product]))

vluwangmsft_0-1653378457547.png

sunmtableb = calculate(SUM(TableB[value]),ALLEXCEPT(TableB,TableB[Product]))

vluwangmsft_1-1653378475031.png

Relationship:

vluwangmsft_2-1653378488936.png

Difference:

Difference = [sumtablea]-LOOKUPVALUE(TableB[sunmtableb],TableB[Product],MAX(TableA[Product]))

Outputresult:

vluwangmsft_3-1653378572685.png

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


Best Regards

Lucien

View solution in original post

5 REPLIES 5
v-luwang-msft
Community Support
Community Support

Hi  @ash_cool10 ,

Refer the below:

sumtablea = CALCULATE(SUM(TableA[value]),ALLEXCEPT(TableA,TableA[Product]))

vluwangmsft_0-1653378457547.png

sunmtableb = calculate(SUM(TableB[value]),ALLEXCEPT(TableB,TableB[Product]))

vluwangmsft_1-1653378475031.png

Relationship:

vluwangmsft_2-1653378488936.png

Difference:

Difference = [sumtablea]-LOOKUPVALUE(TableB[sunmtableb],TableB[Product],MAX(TableA[Product]))

Outputresult:

vluwangmsft_3-1653378572685.png

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


Best Regards

Lucien

Hi Lucien,

 

Thank you so much for your support. I tried and i got the result .

 

I appreicate your help.

 

Regards,

Ashish

negi007
Community Champion
Community Champion

@ash_cool10 use the same process that you do to create a calculated column and a measure

1. first create a calculated columns

2. create your first measure

3. then create your measure to calc difference between 1. calculated column 2. measure

 

in case you face any challenge, please sample data to create above calc




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



Proud to be a Super User!


Follow me on linkedin

Hi @negi007,

 

I tried creating the same but nothing is working out. 

It gives error "a table of multiple values was supplied where a single value was expected" when i used Lookup value fucntion to call Calculated COlumn value inn Table 1.

 

Can you please elaborate some more?

 

Thanks.

A

@ash_cool10  why do you need to use lookup function. both tables are already linked to each other through relationship you have created as mentioned by you.

 

let say you first create a calculated column like 

1. Profit_Est = Orders[Profit]*1.5
 
then you create a measure in the second table like below
2. Returns = sum(Returns[value])
 
then you create a measure like below
Profit_Returns = SUM(Orders[Profit_Est])-[Returns]
 
i hope it can direct you in the right direction. for exact help would it be possible for you to share your pbix file or data in text format. thanks
 



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



Proud to be a Super User!


Follow me on linkedin

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.