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
SuperSayan
Resolver I
Resolver I

Sum data by dates from 2 different tables

Hi Everyone,

 

I'm trying to sum data from 2 different tables. Here is a simplification of the data:

Table 1:

- Column 1: date of sale

- Column 2 : price of sale

A lot of other columns

 

Table 2:

- Column 1 : date of another type of sales

- Column 2 : price

Few other columns.

 

 

I don't want to append both table because I have a lot of visuals based on table 1 and I don't want to add rows without all the columns as it will mess up my visualisation.

My goal is to be able to sum all the prices from both table in a measure (that's the easy part) and being able to visualise by month or year. The issue being both table have their own date reference.

 

I'm not sure this is very clear, don't hesitate if you need more info.

1 ACCEPTED SOLUTION

@SuperSayan,

 

Create a calendar table and build relationship on date column with your existing tables.

Community Support Team _ Sam Zha
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

8 REPLIES 8
Greg_Deckler
Super User
Super User

Are these tables related to one another?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler, they are not related. However they have a common  attribute (salesman). This value is not unique in any of those table but I have a salesman table so I could link both table through this salesman table.


Would that help?

Yes, if you link the tables then you could theoretically use the date column from either one of them, just depends on how you want to slice it.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I have linked the table in the below manner:

 

Table1[Salesman]    n-->1     SalesmanTable[Salesman]   1<--n      Table2[Salesman]

 

However, when I try to visualise my measure in an histogram by month, I get the same value for each month which is a clear indication that PowerBI doesn't know how to manage the date slicer.

 

Mesure is more or less the below:

SUMX(Table1, Table1[Price])+SUMX(Table2, Table2[Price])

@SuperSayan,

 

Create a calendar table and build relationship on date column with your existing tables.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-chuncz-msft,

 

I was a bit reluctant to go down that road but at this point it looked like a good way out.

So I did that and I got a very surprising behaviour.

 

I am using one date from a table in different measure with the year info (example below), sorry my Power BI is in French...

But the error message is not very complicated, it is telling me that the date in my table (that I linked to the calendar table) has no "Year" attribute... I confirm my data is Date type (dd/mm/yyyy format).

 

réalisé 2017 = COUNTROWS(FILTER(HistoriqueInter;HistoriqueInter[FinréelleDateH].[Year]=2017))

 

Date error.JPG

 

PS: As soon as I remove the relationship on the date between my content table and the calendar table, the measure is working again...

@SuperSayan,

 

You got the point. Use YEAR Function instead.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft

Works fine, don't know why it changes the behaviour or why I didn't think about that workaround myself.
Thanks!

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.