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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
godinbl
Frequent Visitor

Trying to build a table based on multiple lists that contains calculated values from other lists

I apologize in advance I am a newbie to Power Bi but I have done a lot of searching this forum and Youtube videos and can't seem to find the answer to my problem:

 

I have created a table in Power Bi based on the following Sharepoint Lists:

Meter Readings

Auths

AEs

SWANs

 

The common field in all these lists is called "auth" and the relationships are many to many - I have created those already

The table is primarily based on Meter Readings and I can pull data fields in from the other lists as you can see from my screenshot but I need to create a calculated column called "Entitlement" which should be:
Auths[volumeML]+SWANs[SWAN]*AEs[AE]+Auths[S&D]+Auths[PA]

 

I also need to group the table by auth - not sure of the best way to achieve that - any help greatly appreciated  thanking you 🙂

powerbi-table.png

1 ACCEPTED SOLUTION

Hi @godinbl 

You can try the following.

CALCULATE (
    SUM ( 'SWANs List'[amount] ),
    'SWANs List'[Auth] = _auth,
    'SWANs List'[expirydate] >= MIN ( 'MeterReading'[readdate] ),
    'SWANs List'[expirydate] <= MAX ( 'MeterReading'[readdate] )
)

Best Regards!

Yolo Zhu

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

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with, explain the question and show the expected result.  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

My table - based primarily on Meter Readings Sharepoint List:

Entitlement = volumeML + amount * thisyear + S&D + PA

 

Expecteds result from calculations involving red text fields:

AuthClientNameClientRefWMAZoneEntitlement
123456Joe Bloggs435621FitzroyZone 157
234567Bill Nobody657891CometZone B104
987654Mrs Brown87654Isaac ConnorsZone 1233.5

 

Auths List:

AuthClientNamevolumeMLS&DPA
123456Joe Bloggs5025
234567Bill Nobody4020
987654Mrs Brown20216.5

 

SWANs List:

AuthClientNameamount
123456Joe Bloggs0
234567Bill Nobody80
987654Mrs Brown0

 

AEs List:

AuthClientNamethisyear
123456Joe Bloggs1
234567Bill Nobody0.85
987654Mrs Brown0.75

Hi,

Thanks for the solution godinbl offered, and i want to offer some more information for user to refer to.

 

hello @godinbl , based on the function you have offered, the entitlement for 234567 should be 110 and the entitlement for 987654 should be  38.5 you can refer to the following calculated column.

Column =
VAR _auth = [Auth]
VAR _sumauthslist =
    CALCULATE (
        SUM ( 'Auths List'[volumeML] ) + SUM ( 'Auths List'[S&D] )
            + SUM ( 'Auths List'[PA] ),
        'Auths List'[Auth] = _auth
    )
VAR _amo =
    CALCULATE ( SUM ( 'SWANs List'[amount] ), 'SWANs List'[Auth] = _auth )
VAR _thisyear =
    CALCULATE ( SUM ( 'AEs List'[thisyear] ), 'AEs List'[Auth] = _auth )
RETURN
    _sumauthslist + _amo * _thisyear

Output

vxinruzhumsft_0-1728962823934.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xinruzhu-msft thanks for your response but my calculations are correct - perhaps you misunderstood the logic or I did not explain properly:

 

The calculation is: Entitlement = volumeML + amount * thisyear + S&D + PA

For auth 234567 the calculation is as follows:

Entitlement = 40 + 80 * 0.85 + 2 + 0 and the answer is 104

 

For auth 987654 the calculation is:

Entitlement = 20 + 0 * 0.75 +2 + 16.5 and the answer is 33.5

 

The order that the calculation is carried out is important to the final figure so it has to be left to right as seen above.

hope this clarifies things a little

thanks again for your help!

Hi @godinbl 

Thanks for your quick reply, do you mean  (40 + 80) * 0.85 + 2 + 0  and   (20 + 0) * 0.75 +2 + 16.5 , you can refer to the following.

Column =
VAR _auth = [Auth]
VAR _vol =
    CALCULATE ( SUM ( 'Auths List'[volumeML] ), 'Auths List'[Auth] = _auth )
VAR _amo =
    CALCULATE ( SUM ( 'SWANs List'[amount] ), 'SWANs List'[Auth] = _auth )
VAR _thisyear =
    CALCULATE ( SUM ( 'AEs List'[thisyear] ), 'AEs List'[Auth] = _auth )
VAR _sumsd_pa =
    CALCULATE (
        SUM ( 'Auths List'[S&D] ) + SUM ( 'Auths List'[PA] ),
        'Auths List'[Auth] = _auth
    )
RETURN
    ( _vol + _amo ) * _thisyear + _sumsd_pa

Output

vxinruzhumsft_0-1729041818279.png

 

Best Regards!

Yolo Zhu

thank you very much for your solution to my previous problem - I have one more thing to add to the calculations:

 

I am filtering my report on a field called "readdate" from the MeterReadings list and I have added a Slicer to the page so I have a datepicker that the user can choose between 2 dates for their report. Essentially the user is looking for Meter Readings where the readdate is between these 2 dates.

 

The SWANs list also has a date field; in this case 'SWANs'[expirydate] which should also be BETWEEN my start and end dates in the Slicer

 

How can I add a little bit of code to this line: 

VAR _amo =
    CALCULATE ( SUM ( 'SWANs List'[amount] ), 'SWANs List'[Auth] = _auth )

 

so that the SWANs[amount] will only be included in the report when the expirydate is between start and enddate?

thanks

Hi @godinbl 

You can try the following.

CALCULATE (
    SUM ( 'SWANs List'[amount] ),
    'SWANs List'[Auth] = _auth,
    'SWANs List'[expirydate] >= MIN ( 'MeterReading'[readdate] ),
    'SWANs List'[expirydate] <= MAX ( 'MeterReading'[readdate] )
)

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thank you so much for assistance provided so far - could you possibly help with one more thing:

I have to group the report by the "auth" field and I have done this by adding the auth field to a new table and putting this code in: 

Table2 = SUMMARIZE('MeterReadings','MeterReadings'[auth])
 
However, when I calculate the usage I need to group by "meterref" from the MeterReadings table so that I take the difference between the MAX and MIN "exactreading", GROUPBY "meterref" and then SUM all values to get the "Usage" figure
 
The MeterReadings table looks like this:
MeterRefAuthreaddateexactreading
178111137AP682915/06/20234,958.89
178111137AP682917/06/20246,157.09
178121139AP682915/06/202316,394.65
178121139AP682917/06/202419,752.88
178711139AP682915/06/20233,161.49
178711139AP682917/06/2024 620.53
178711139AP682916/01/20240

 

Expected results are:

1137AP6829 Total Usage = 1198.20

1139AP6829 Total Usage = 6519.72

 
This is what the Usage calculation is currently:
Usage = CALCULATE((MAX(MeterReadings[exactreading])-(MIN(MeterReadings[exactreading]))),'MeterReadings'[readdate] >= MIN ( 'MeterReadings'[readdate] ),
    'MeterReadings'[readdate] <= MAX ( 'MeterReadings'[readdate] ))
thanking you again...

thank you!

Hi,

Using the LOOKUPVALUE() function in calulcated column formulas, bring over the red coloured columns from the last 3 tables into the first table.  Thereafter, create another calculated column formula for your final calculation.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.