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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.