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
Sean500
Frequent Visitor

How to take the target value from one table to subtract from other table?

Hi 

 

I have two tables as follow

 

Table: Target

 

Sean500_3-1684911515535.png

 

 

Target Table is unique table. It has four projects, tasks, Layout and target for each.

 

Table: Actual

 

Sean500_1-1684911269441.png

 

Actual table has month, sales for each project according to Layout and task. At present only three project has been sold. 

 

Both the table has been connected through Custom column 

 

Sean500_2-1684911330722.png

 

What I need?

 

I need to calculate Remaining sales = Target - Total Sales. Target from Target table and Total Sales from Actual table.

Please note target table doesn't have date or month.

 

Once I calculate the Remaining sales, I need to visualize by Month.  I did by using below dax measures

 

Remaining Sales = SUM(Target[Target]) - SUM(Actual[Total Sales])

 

Sean500_4-1684911592318.png

 

The remaining sales values are wrong, I think it's not taking the month properly as target table doesn't have one. Can anyone advise how to fix this?

 

Attached power bi file. https://we.tl/t-jyuLdOuN0R

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Sean500 ,

 

Please try:

First create a new table:

vjianbolimsft_0-1685352289577.png

Then build relationship:

vjianbolimsft_1-1685352312962.png

Apply the measure:

Remaining Sales = 
var _a = ALLSELECTED(Project[Project])
return SUM(Target[Target]) - CALCULATE(SUM(Actual[Total Sales]),FILTER(ALL(Actual),[Project] in _a&&[Date]<=MAX('Actual'[Date])))

Output:

vjianbolimsft_2-1685352406952.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Sean500
Frequent Visitor

Thanks @v-jianboli-msft  It is correct against month. However, when I use Project as a filter, the values are not correct Can you please confirm?

Hi @Sean500 ,

 

Please try:

First create a new table:

vjianbolimsft_0-1685352289577.png

Then build relationship:

vjianbolimsft_1-1685352312962.png

Apply the measure:

Remaining Sales = 
var _a = ALLSELECTED(Project[Project])
return SUM(Target[Target]) - CALCULATE(SUM(Actual[Total Sales]),FILTER(ALL(Actual),[Project] in _a&&[Date]<=MAX('Actual'[Date])))

Output:

vjianbolimsft_2-1685352406952.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-jianboli-msft
Community Support
Community Support

Hi @Sean500 ,

 

Please try:

Remaining Sales = SUM(Target[Target]) - CALCULATE(SUM(Actual[Total Sales]),FILTER(ALL(Actual),[Date]<=MAX('Actual'[Date])))

Output:

vjianbolimsft_0-1685078951868.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.