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
Ireneliu
Regular Visitor

Difference between two tables

Hello Everyone,

 

I have a question about the diference between two tables.

A Table is for department's actual results.

B Table is for department's budget.

When the actual results have a value, I can't get a correct value, even no value.

1560912070206.jpg

I want to have values by month.

Please suggest the DAX measure.

Thank you!

7 REPLIES 7
Stachu
Community Champion
Community Champion

can you share your current syntax, and the underlying tables?

as described here
How to Get Your Question Answered Quickly 



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hello @Stachu ,

 

It was my first time publishing a question here, sorry for the incomplete information.

 

Columns for Table A are Department、AccountName、Date、accountingcurrencyamount

Columns for Table B are Department、AccountName、Date、budget

The relationship between two tables is "AccountName".
(Cardinality:many to many. Cross filter direction:both.)

 

*Measure for actual results = CALCULATE(SUM('A'[accountingcurrencyamount]),

FILTER('A',[AccountName]="Salary"|| [AccountName]="Retirement pension")

*Measure for budget = CALCULATE(SUM('B'[departmentbudget]),

FILTER('B',[AccountName]="Salary"|| [AccountName]="Retirement pension")

I used "FILTER" to choose the AccountName I need.

*Measure for difference = [Measure for actual results]-[Measure for budget]


I tried to change the relationship become Date yesterday, and got the following result.

I still can't get the right values when actual results have value...

1560996257179.jpg

 

Stachu
Community Champion
Community Champion

do the following:

1) create a new table for calendar, e.g.

Calendar = CALENDARAUTO()

2) mark the Calendar tables as Date table
3) create 1:many  joins between Calendar table and both budget and actuals

4) use the month from calendar table in the visual

5) set the join between A & B tables to be done on Department



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

I followed up the steps you suggested but having a trouble in step 3.

The relationship between Calendar table and both budget and actuals can't be active at the same time.

Stachu
Community Champion
Community Champion

Hmm, that's probably because of the many:many relationship

 

can you add a new table for Departments, e.g. like this:

Departments =
DISTINCT (
    UNION ( VALUES ( TableA[Departments] ), VALUES ( TableB[Departments] ) )
)

deactivate/remove your existing many:many relationship between Actuals and Budgets

create new 1:many relationships from Departments to tables A and B

do the same for the Calendar table



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Sorry for late reply.

I tried to change the relationships.

However, when I choose Retirement pension to make sure the difference value is right or not,
finding out the value of Actural results of Salary is included.

Is it because of there is no relationship about AccountName between table A and B?

I create a new table for Account Name and make 1:many relationships from Account Name to tables A and B.

Finally,getting the right value.

 

 

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.

Top Solution Authors