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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JBorja
Frequent Visitor

Calculated Column not Filtering

Hello all,

I have the following calculated column in table 'SO Issues  Key':

 

Count Issues 2 = 
VAR a = CALCULATE(
    COUNTROWS(SO_Detail), 
        FILTER(SO_Detail, 'SO Issues Key'[SO Line Notes Designator] = SO_Detail[Current Issue 1] || 'SO Issues Key'[SO Line Notes Designator] = SO_Detail[Current Issue 2] || 'SO Issues Key'[SO Line Notes Designator] = SO_Detail[Current Issue 3])
    )
RETURN IF(
    ISBLANK(a), 
    0, a
    )

 

'SO Issues Key' has a one to many relationship to 'SO_Detail' by the columns [SO Line Notes Designator] and [Current Issue 1] , respectively, and separate inactive relationships between the same 'SO Issues Key' column and [Current Issue 2] and [Current Issues 3].

 

For one row, this calculated column should = 50. When I apply a filter to column in 'SO Detail', that same column should = 1, but it stays at 50. Can anyone help with this?

 

Thanks!

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @JBorja 
Calculated columns aren't working with filters.
They are a kind of "static"

All logic that you need "on the flight" shoul be calculated with the measures.

 

For a more detailed solution 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Anonymous
Not applicable

Hi  @JBorja ,

 

 

Here are the steps you can follow:

1. Create measure.

All =
var _select=SELECTEDVALUE('SO Detail'[Account Mgr])
var _CONCATENATEX=
CONCATENATEX(
    FILTER(ALL('SO Detail'),
    'SO Detail'[Account Mgr]=_select),'SO Detail'[Current Issue(s)],",")
return
DIVIDE(
LEN(_CONCATENATEX)-
LEN(
SUBSTITUTE(_CONCATENATEX,MAX('SO Issues Key'[SO Issues]),"")),LEN(MAX('SO Issues Key'[SO Issues])))

2. Result:

vyangliumsft_0-1698050186124.png

 

 

Best Regards,

Liu Yang

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

3 REPLIES 3
Anonymous
Not applicable

Hi  @JBorja ,

 

 

Here are the steps you can follow:

1. Create measure.

All =
var _select=SELECTEDVALUE('SO Detail'[Account Mgr])
var _CONCATENATEX=
CONCATENATEX(
    FILTER(ALL('SO Detail'),
    'SO Detail'[Account Mgr]=_select),'SO Detail'[Current Issue(s)],",")
return
DIVIDE(
LEN(_CONCATENATEX)-
LEN(
SUBSTITUTE(_CONCATENATEX,MAX('SO Issues Key'[SO Issues]),"")),LEN(MAX('SO Issues Key'[SO Issues])))

2. Result:

vyangliumsft_0-1698050186124.png

 

 

Best Regards,

Liu Yang

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

Ritaf1983
Super User
Super User

Hi @JBorja 
Calculated columns aren't working with filters.
They are a kind of "static"

All logic that you need "on the flight" shoul be calculated with the measures.

 

For a more detailed solution 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 ,

 

Thanks for you response. I tried using a measure instead, and I got an error when loading into a visual, which states "MdxScript(Model)(7, 71)...A table of multiple values was supplied where a single value was expected".

 

Here's the code used in the measure:

 

 

Count Issues =
VAR x = SUMMARIZECOLUMNS('SO Issues Key'[SO Issues])
VAR a = CALCULATE(
    COUNTROWS(SO_Detail),
        FILTER(SO_Detail, CONTAINSSTRING(SO_Detail[Current Issue(s)], x)
    )
)
RETURN IF(
    ISBLANK(a),
    0, a
    )

I'm still not sure what I'm messing something up.

 

Here's an example of my data tables:

SO Issues Key

SO IssuesCount Issues (measure/calculated)

Pricing

3
Credit4
Shipping3

 

SO Detail

Account MgrSOCurrent Issue(s)
Alex1111

Pricing, Credit

Brandon2222Shipping
Alex3333Pricing
Alex4444Shipping, Credit
Emily5555Pricing, Credit, Shipping
Emily6666Credit

 

If I filter for Emily, I would expect the SO Issues Key table to look like this:

SO IssuesCount Issues (measure/calculated)

Pricing

1
Credit2
Shipping1

 

Does it still make sense to use a measure for this data? If so, what's wrong with the formula I used?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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