Forum Discussion

Frixel's avatar
Frixel
Post Prodigy
9 months ago
Solved

Error in create measure for filter

Hello,

 

I try to make a filter for multiple filters(42) and create this measure but it gives this error.

What is the problem?

also created this 

 

 

  • Hi Frixel 

    you cant use a column directly in a measure like that.the formula that you have shown in screenshot will work for new column not new measure.

    try below :

    Filter DC= 
    IF(
        MAX('ontvangen'[From] )="[email protected]",
        TRUE(),
        FALSE()
    )
    Filter DC= 
    IF(
        SELECTEDVALUE('ontvangen'[From] )="[email protected]",
        TRUE(),
        FALSE()
    )

     

    Please give Kudos or mark it as solution once confirmed.

     

    Thanks and Regards,

    Praful

     

     

     

9 Replies

  • Hii Frixel 

     

    The error appears because you are trying to use a column that is created as a measure (Filter DC) inside a row-level filter of CALCULATE().
    Power BI does not allow using measures in a TRUE/FALSE filter expression  only columns can be used.

    So this:

    '... ontvangen'[Filter DC] = TRUE()

    fails because Filter DC is a measure, not a column.

    If you want to filter rows, you must create a calculated column instead:

    Filter DC Column =
    
    IF ( '... ontvangen'[YourCondition] = "Something", TRUE(), FALSE() )

    Then use it in your measure:

    DC_Filter =
    CALCULATE (
        COUNTROWS ( '... ontvangen' ),
        '... ontvangen'[Filter DC Column] = TRUE()
    )

    This is the only valid way  a measure cannot be used as a row filter in CALCULATE().

  • Hi Frixel 

    Try Below Measure:

    # DC_Filter = 
    CALCULATE(
        COUNTROWS('ontvangen'),
        FILTER(
            'ontvangen',
            [Filter DC] = TRUE()
        )
    )

     

    Please give kudos or mark it as solution once confirmed.

    Thanks and Regards,

    Praful

     

     

    • Frixel's avatar
      Frixel
      Post Prodigy

      yes i can create that measure but when i then create the filter in ....ontvangen then this error.

      And the 'From' is not inserted by power bi but by myself.

       

       

      • Praful_Potphode's avatar
        Praful_Potphode
        Super User

        Hi Frixel 

        you cant use a column directly in a measure like that.the formula that you have shown in screenshot will work for new column not new measure.

        try below :

        Filter DC= 
        IF(
            MAX('ontvangen'[From] )="[email protected]",
            TRUE(),
            FALSE()
        )
        Filter DC= 
        IF(
            SELECTEDVALUE('ontvangen'[From] )="[email protected]",
            TRUE(),
            FALSE()
        )

         

        Please give Kudos or mark it as solution once confirmed.

         

        Thanks and Regards,

        Praful

         

         

         

    • rohit1991's avatar
      rohit1991
      Super User

      Hii Frixel 

       

       

      Your calculated column must be a pure row-level expression, for example:

      Filter DC Column =
      IF ( '… ontvangen'[SomeColumn] = "Something", TRUE(), FALSE() )
      • must reference only columns
      • must not use measures
      • must evaluate per row

      Once the column becomes a valid boolean column, this measure will work without error:

      • Frixel's avatar
        Frixel
        Post Prodigy

        😥Hi rohit1991 

        I don`t get here the 'From' in the code.
        (what I want is to count the emails that match a specific sender.) (42 sender adresses)

         

         

         

  • v-hjannapu's avatar
    v-hjannapu
    Community Support

    Hi Frixel,

    I would also take a moment to thank Praful_Potphode  , rohit1991  for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
     

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

    Regards,
    Community Support Team.

    • v-hjannapu's avatar
      v-hjannapu
      Community Support

      Hi Frixel,
      I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We are always here to support you.


      Regards,
      Community Support Team.