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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
zenton
Helper II
Helper II

Calculation using multiple filtered values from same column

Hi

I am trying to calculte energy usage using filtered values from the same column.

this is the calcultion I am trying to resolve. 

I get the error below.

A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

 

Bondi Use = CALCULATE(
SUM(Energy[Value]),Filter(Energy,Energy[Meter]="CB0NCGN01N (MWh)")+
SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00017 (MWh)")+
SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-EXP (MWh)") -
SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-IMP (MWh)")
)

1 ACCEPTED SOLUTION
zenton
Helper II
Helper II

Hi,

I managed to get the correct result using variables. I am not sure if this is the most efficient way to do this.

 

Bondi Use =
VAR A = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="CB0NCGN01N (MWh)"))
VAR B = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00017 (MWh)"))
VAR C = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-EXP (MWh)"))
VAR D = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-IMP (MWh)"))
Return
CALCULATE(A+B+C-D)

View solution in original post

5 REPLIES 5
zenton
Helper II
Helper II

Hi,

I managed to get the correct result using variables. I am not sure if this is the most efficient way to do this.

 

Bondi Use =
VAR A = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="CB0NCGN01N (MWh)"))
VAR B = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00017 (MWh)"))
VAR C = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-EXP (MWh)"))
VAR D = CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-IMP (MWh)"))
Return
CALCULATE(A+B+C-D)

Hi,

 

Try this measure

 

=CALCULATE(SUM(Energy[Value]),Filter(Energy,Energy[Meter]="NCCCX00018-IMP (MWh)"||Energy[Meter]="NCCCX00018-EXP (MWh)"||Energy[Meter]="NCCCX00017 (MWh)"||Energy[Meter]="CB0NCGN01N (MWh)"))

 

Hope this helps.

 

 


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

Hi Thanks for you help but the solutions only allow you to perform one function like SUM() or COUNT() for all of the filter results. I need to do something different with each filtered value like sum, divide, subtract, multiply. A + B + C x D

Hi @zenton,

 

If so, I'm afraid your solution could be the only choice. Maybe the plus parts (+) could be optimized. You can sum them together.

 

 

Best Regards,

Dale

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

Hi @zenton,

 

Try these two formulas below please. You can use either of them according to your requirement.

Bondi Use =
CALCULATE (
    SUM ( Energy[Value] ),
    Energy[Meter]
        IN {
            "CB0NCGN01N (MWh)",
            "NCCCX00017 (MWh)",
            "NCCCX00018-EXP (MWh)",
            "NCCCX00018-IMP (MWh)" }
)

 

 

Bondi Use =
CALCULATE (
    SUM ( Energy[Value] ),
    FILTER (
        Energy,
        Energy[Meter]
            IN {
                "CB0NCGN01N (MWh)",
                "NCCCX00017 (MWh)",
                "NCCCX00018-EXP (MWh)",
                "NCCCX00018-IMP (MWh)" }
    )
)

Best Regards,

Dale

 

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

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors