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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rssilvaba
Resolver II
Resolver II

SUM from another table gives wrong number even with relationship

Hi All,

I have the following data in "Plans" Table

MarketIdMonthYearRequests
3412202011
34420206
342202012
348202018
349202020
344202014

 

And in the "Requests" Table

CreatedMarketId
2020/09/0334
2020/12/0434
2020/12/1035

 

I already have a relationship from both to a separeted table for the market names but I get the wrong results. the data in the table is more but for this example I tried to limit the data just to show.

So, how can I get the number of Requests from table "Plans" based on the month/year and the market? in this case the sum value I get should be 31 for marketid "34"

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@rssilvaba , Second table has date, The first on can date

 

Date = Date([year], [Month],1)

I am nor sure how they are related now. But they can either join on the date columns . or join to common date table .

 

Can you share data model and expected output

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@rssilvaba , Second table has date, The first on can date

 

Date = Date([year], [Month],1)

I am nor sure how they are related now. But they can either join on the date columns . or join to common date table .

 

Can you share data model and expected output

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @AllisonKennedyCreating a calendarauto table and using @amitchandak solution worked for me. the only drawback for that is if we need to drilldown to the days, but we not doing that with this report so it should be fine.

Thanks all.

Glad it's working! You should be able to get it working for days if/when needed with a DimDate table, so let us know how you get on if that becomes a requirement.

 

https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

Which month/year gives 31? How have you created your relationships? It sounds like you are not accounting for the month/year in the relationships so that may be part of the problem. We need a bit more info to help out here please - screenshot of model view would be a good start. https://excelwithallison.blogspot.com/2020/08/its-complicated-relationships-in-power_11.html

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy I tried to reference that columns to the created date. But I am not sure I know how. If I try to refer to a diferent table column as in the DAX below using calculate and filter it does not allow me to refer to a diferent column.

To @lkalawski, sorry I am not that experienced with DAX or PowerBI so I have no idea how I can intersect the data to get the matches I need. If you can point me to some examples I can try to apply them to my problem.

@rssilvaba can you please share screenshot of your model view and specify which columns are being used for the relationships?

Also, if you are wanting info by month, you should have a DimDate table - do you have one of these yet?

https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

lkalawski
Super User
Super User

Hi @rssilvaba

If you only have a relationship to market name, then there is no date differentiation, so you see more values than you should.

Proposed solutions:
1. You can create a concatenate key in both tables which will consist of market, year and month - example: 34202012. And then you will join both tables by these keys.
2. If you have a relation, you need to create a measure:

Calculate (Sum (Plans [Requests]), MONTH (Created) = Plans [Month], YEAR (Created) = Plans [Year])

 



_______________
If I helped, please accept the solution and give kudos! 😀

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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