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
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
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.