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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
dmartiprev
Frequent Visitor

Sum data from another table with different aggregation of time

I have two tables: DailyData and MonthlyData. 

 

In the DailyData table, I have columns: "Date", "YrMo" which is shows the year and month that the Date resides in, and I have a third column of data called "Sales".  

 

In the MonthlyData table I only have one column "YrMo".  I would like to sum all the Sales data from the DailyData table into the MonthlyData table by matching the YrMo column. 

 

I have tried to make this both as a column and as a measure and neither seems to work: 

MonthlySalesTotal = CALCULATE(SUM(DailyData[Sales]),DailyData[YrMo]=MonthlyData[YrMo]).
 
Power BI doesn't seem to recognize the MonthlyData[YrMo].  I am getting a message that says "This expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression"  there is only be one table called DailyData with a column called "YrMo" and only one table called MonthlyData with a column called "YrMo".  Although, it is true that within the DailyData table there are multiple rows with the same YrMo since all dates that are within one month of time will have the same YrMo by design.  I thought this is how i could use the calculation function to aggregate to monthly table but maybe this is the cause for the error?
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @dmartiprev ,

 

Based on your description, I have creeated a simple sample:

vjianbolimsft_4-1678240480712.png

vjianbolimsft_3-1678240376416.png

If you need a measure:

Measure = CALCULATE(SUM(DailyData[Sales]),FILTER(ALL(DailyData),[YrMo]=MAX('MonthlyData'[YrMo])))

Output:

vjianbolimsft_5-1678240513889.png

If you need a column:

Column = SUMX(FILTER('DailyData',[YrMo]=EARLIER(MonthlyData[YrMo])),[Sales])

Output:

vjianbolimsft_6-1678240580794.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

2 REPLIES 2
dmartiprev
Frequent Visitor

Thank you, this worked!

v-jianboli-msft
Community Support
Community Support

Hi @dmartiprev ,

 

Based on your description, I have creeated a simple sample:

vjianbolimsft_4-1678240480712.png

vjianbolimsft_3-1678240376416.png

If you need a measure:

Measure = CALCULATE(SUM(DailyData[Sales]),FILTER(ALL(DailyData),[YrMo]=MAX('MonthlyData'[YrMo])))

Output:

vjianbolimsft_5-1678240513889.png

If you need a column:

Column = SUMX(FILTER('DailyData',[YrMo]=EARLIER(MonthlyData[YrMo])),[Sales])

Output:

vjianbolimsft_6-1678240580794.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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.