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
Anonymous
Not applicable

Calculation by Category

Hello All, 

I have a table 

need to add a calculated column the calculation is 

Paid Cost = sum of Planned cost + Sum of Substation/count of Circuit 

SubstationCircuit NamePlanned Cost
ArdmoreArdmore 24$14,793
ArdmoreArdmore 24$32,603
ArdmoreArdmore 24$40,000
ArdmoreArdmore 24$118,000
ArdmoreArdmore 24$383,180
ArdmoreArdmore 24$1,064,590
BellcowBellcow 21$19,279
BellcowBellcow 21$26,091
BellcowBellcow 21$35,000
BellcowBellcow 21$190,000
BellcowBellcow 21$463,180
BellcowBellcow 21$848,958
BellcowBellcow 50$12,476
BellcowBellcow 50$25,000
BellcowBellcow 50$27,383
BellcowBellcow 50$124,500
BellcowBellcow 50$298,180
BellcowBellcow 50$902,740
BellcowSubstation$1,919
BellcowSubstation$8,392
BellcowSubstation$15,000
BellcowSubstation$50,000
BellcowSubstation$84,330
BellcowSubstation$200,000

 

for Ardmore there is no Substation so the Paid Cost = sum of Planned cost which is $1,653,166

 

SubstationCircuit NamePlanned CostPaid Cost 
ArdmoreArdmore 24$14,793$1,653,166
ArdmoreArdmore 24$32,603$1,653,166
ArdmoreArdmore 24$40,000$1,653,166
ArdmoreArdmore 24$118,000$1,653,166
ArdmoreArdmore 24$383,180$1,653,166
ArdmoreArdmore 24$1,064,590$1,653,166

 

but for Bellcow we have 2 Circuit and substation Note the 2 is the count of Circuit for Bellcow it will be different for each Circuit 

 

sum of Bellcow 50=  $1,390,279 (124,500+902,740+12,476+27,383+298,180 +25,000)

sum of Bellcow 21 = $1,582,508(190,000+848,958+19,279+26,091+463,180+35,000)

sum of Substation = $359,641(84,330+15,000+50,000+200,000+1,919+8,392

 

now the Paid Calculation =  sum of Bellcow 50+(sum of Substation/2)

                                              sum of Bellcow 21+(sum of Substation/2)

SubstationCircuit NameCircuit Number Planned Cost  Paid Cost
BellcowBellcow 50710450 $        124,500$1,570,099.41
BellcowBellcow 50710450 $        902,740$1,570,099.41
BellcowBellcow 50710450 $          12,476$1,570,099.41
BellcowBellcow 50710450 $          27,383$1,570,099.41
BellcowBellcow 50710450 $        298,180$1,570,099.41
BellcowBellcow 50710450 $          25,000$1,570,099.41
BellcowBellcow 21710421 $        190,000$1,762,328.16
BellcowBellcow 21710421 $        848,958$1,762,328.16
BellcowBellcow 21710421 $          19,279$1,762,328.16
BellcowBellcow 21710421 $          26,091$1,762,328.16
BellcowBellcow 21710421 $        463,180$1,762,328.16
BellcowBellcow 21710421 $          35,000$1,762,328.16
BellcowSubstation  $          84,330$359,640.80
BellcowSubstation  $          15,000$359,640.80
BellcowSubstation  $          50,000$359,640.80
BellcowSubstation  $        200,000$359,640.80
BellcowSubstation  $            1,919$359,640.80
BellcowSubstation  $            8,392$359,640.80
1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this expression in your calculated column.

 

Paid Cost =
VAR stationtotal =
    CALCULATE (
        SUM ( Cost[Planned Cost] ),
        ALLEXCEPT ( Cost, Cost[Substation], Cost[Circuit Name] )
    )
VAR substationcost =
    CALCULATE (
        SUM ( Cost[Planned Cost] ),
        ALLEXCEPT ( Cost, Cost[Substation] ),
        Cost[Circuit Name] = "Substation"
    )
VAR circuitcount =
    CALCULATE (
        DISTINCTCOUNT ( Cost[Circuit Name] ),
        ALLEXCEPT ( Cost, Cost[Substation] ),
        Cost[Circuit Name] <> "Substation"
    )
RETURN
    IF (
        Cost[Circuit Name] = "Substation",
        stationtotal,
        stationtotal + substationcost / circuitcount
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

If the above post helps, please kindly mark it as answer to help others find it more quickly. if not, please kindly elaborate more.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
mahoneypat
Employee
Employee

Please try this expression in your calculated column.

 

Paid Cost =
VAR stationtotal =
    CALCULATE (
        SUM ( Cost[Planned Cost] ),
        ALLEXCEPT ( Cost, Cost[Substation], Cost[Circuit Name] )
    )
VAR substationcost =
    CALCULATE (
        SUM ( Cost[Planned Cost] ),
        ALLEXCEPT ( Cost, Cost[Substation] ),
        Cost[Circuit Name] = "Substation"
    )
VAR circuitcount =
    CALCULATE (
        DISTINCTCOUNT ( Cost[Circuit Name] ),
        ALLEXCEPT ( Cost, Cost[Substation] ),
        Cost[Circuit Name] <> "Substation"
    )
RETURN
    IF (
        Cost[Circuit Name] = "Substation",
        stationtotal,
        stationtotal + substationcost / circuitcount
    )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.

Top Solution Authors