Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
The following problem concerns just one table so no Lookups to other tables are needed
I am also a complete newbie to PowerBi.
I am trying to group the data in a table called MeterReadings by "auth" and then by "meterref"
A meter reading has an auth, a readdate and can have multiple meterrefs attached to it.
I need to calculate the difference between the minimum and maximum meter reading values (called the usage) between 2 dates (the date field is called "readdate"). What I specifically need to do is calculate the usage by meterref, between the 2 dates and SUM these values, then SUM all values under that auth
meterref auth readdate meterreading
17811 1137AP6829 15/06/2023 4,958.89
17811 1137AP6829 17/06/2024 6,157.09
17812 1139AP6829 15/06/2023 16,394.65
17812 1139AP6829 17/06/2024 19,752.88
17871 1139AP6829 15/06/2023 3,161.49
17871 1139AP6829 17/06/2024 620.53
17871 1139AP6829 16/01/2024 0
You can see from the above that auth 1137AP6829 has only 1 meterref associated with it (17811)
auth 1139AP6829 however has 2 meterrefs associated with it (17812 and 17871), one of which has a zero reading - this must be taken into account when looking up MIN and MAX values
Expected results from above are:
1137AP6829 Total Usage = 1198.20
1139AP6829 Total Usage = 6519.72
thanks for any assistance 🙂
Solved! Go to Solution.
Hi,
PBI file attached.
Hi - with the data I have shared and explained in my earlier posts the expected results are:
1137AP6829 Total Usage = 1198.20
1139AP6829 Total Usage = 6519.72 - not $817.27
As outlined above the auth has 1 or more meterrefs attached to it so when calculating usage we need to first group on auth, then on meterref and then take the usage for each meterref under that auth and SUM the values as long as the readdate falls between those 2 dates
In the case of auth 1137AP6829 we have:
In the case of auth 1139AP6829 we have:
Now, we need to SUM 3358.23 and 3161.49 to get the correct usage figure of 6519.72
I hope I have given a better explanation to my problem than in my previous posts
thanking you
TotalUsageByAuth =
SUMX(
SUMMARIZE(
MeterReadings,
MeterReadings[auth],
MeterReadings[meterref],
"Usage",
CALCULATE(
MAX(MeterReadings[meterreading]) - MIN(MeterReadings[meterreading])
)
),
[Usage]
)
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
thank you so much @Kedar_Pande - one thing is missing from the calculation - I mustn't have explained it properly:
I need to also filter on readdate - so basically WHERE readdate >= MIN(readdate) and readdate <= MAX(readdate)
thanks
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.