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
nmaddock
Helper I
Helper I

Power Bi Measure giving me a different result to SQL Query

Hi,

 

Im trying to create a new Measure to calculate the kgm3 for our industry types based on jobs that we have done. I have written the query in SQL but the Power BI measure is giving me a different result, the sql query is:

 

 

SELECT IndustryType.Name, 
	SUM(WeighData.Weight) as Weight, 
	SUM(ContainerType.Capacity) as Volume, 
	SUM(WeighData.Weight) / (SUM(ContainerType.Capacity)/1000) as Kgm3  
  FROM  Customer Customer
  INNER JOIN Site Site on Site.CustomerId = Customer.Id
  INNER JOIN Agreement Agreement on Agreement.SiteId = Site.Id
  INNER JOIN ContainerType ContainerType on ContainerType.Id = Agreement.ContainerTypeId
  INNER JOIN IndustryType IndustryType on IndustryType.Id = Site.IndustryTypeId 
  INNER JOIN Job Job on Job.AgreementId = Agreement.Id
  INNER JOIN WeighData WeighData on WeighData.JobId = job.Id
  where job.RecordCreationDate > '2019-01-01'
  group by IndustryType.Name

The results from sql is:

 

sql.jpg

 

The power Bi Measure for Weight is correct but the volume is way off.

power bi.jpg

Here is my model diagram, the relationships Cross filter direction is set to both

 

relationships.jpg

My Measure are:

Total Volume = SUM(ContainerType[Capacity])
Total Weight = SUM(WeighData[Weight])
kg/m3 = [Total Weight] / ([Total Volume] / 1000)
 
I have also applied the same date filter, any help i would much appreciate as I am very new to Power BI so I could be missing something really obvious. 

 

1 REPLY 1
parry2k
Super User
Super User

@nmaddock can you possibly share pbix file wiht sample data, t is bit of complex by looking at relationship diagram. remove any sensitive data before sharing.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.