Forum Discussion

han_rj's avatar
han_rj
Icon for Helper IV rankHelper IV
1 year ago
Solved

overwrite visual filters in calculated column

 

Hi All, Need help overwrite visual filters on the same feild but only for a single row in a table.
I have a calculated column as folows

product_category_new = IF('Product Subcategory'[Subcategory] in {"Bluetooth Headphones","MP4&MP3"},"Audio",
if('Product Subcategory'[Subcategory] in {"Camcorders","Digital Cameras"}, "Camera",IF('Product Subcategory'[Subcategory] IN {"Desktop","Laptops","Printers, Scanners & Fax"}, "Computers")))
 
I need to overwrite the visual filters for a single row where Product Category is Computer alone.
The current view has pre filters like CountryRegion = France or Canada and occupation = Management how to override the filter for row computer with CountryRegion canada and occupation Clerk


Attached is the existing view and the expected view to build, Please may I have help

 

  • Hi han_rj ,

    Thanks for reaching out to the Microsoft fabric community forum.

    SamsonTruong , danextian , 

    Thanks for your prompt response

    han_rj ,
    Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
    Please show the expected outcome based on the sample data you provided.

    Best Regards,

    Lakshmi Narayana

15 Replies

  • When you say computers alone, do you mean to apply the filter for that category alone ane everythign else remains  the same?  Would have been easier for us to understand if you gave us a sample data and from the same sample data, your expected result.

     

    VAR _computersOnly =
        CALCULATE (
            SUM ( tbl[value] ),
            KEEPFILTERS ( 'Product'[category] = "computers" ),
            KEEPFILTERS ( Countryregion[countryregion] = "Canada" ),
            KEEPFILTERS ( occupation[occupation] = "clerk" )
        )
    VAR _other =
        CALCULATE (
            SUM ( tbl[value] ),
            KEEPFILTERS ( 'Product'[category] <> "computers" )
        )
    RETURN
        _computersOnly + _other
    

     

    Note: if filters are from the same table, there's no need to use multiple KEEPFILTERS for that table. Example: 

     KEEPFILTERS ( 'table'[category] = "computers"  &&  'table'[countryregion] = "Canada" )

     

  • v-lgarikapat's avatar
    v-lgarikapat
    Icon for Community Support rankCommunity Support

    Hi han_rj ,

    Thanks for reaching out to the Microsoft fabric community forum.

    SamsonTruong , danextian , 

    Thanks for your prompt response

    han_rj ,
    Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
    Please show the expected outcome based on the sample data you provided.

    Best Regards,

    Lakshmi Narayana

    • v-lgarikapat's avatar
      v-lgarikapat
      Icon for Community Support rankCommunity Support

      Hi han_rj ,

       

      If your issue has been resolved, please consider marking the most helpful reply as the accepted solution. This helps other community members who may encounter the same issue to find answers more efficiently.

      If you're still facing challenges, feel free to let us know we’ll be glad to assist you further.

      Looking forward to your response.

      Best regards,
      LakshmiNarayana.

      • v-lgarikapat's avatar
        v-lgarikapat
        Icon for Community Support rankCommunity Support

        Hi han_rj ,

         

        If your question has been answered, kindly mark the appropriate response as the Accepted Solution. This small step goes a long way in helping others with similar issues.

        We appreciate your collaboration and support!

        Best regards,
        LakshmiNarayana

  • Hi han_rj ,

    To have the sales amount remove the visual filters when the product category is "Computer", you can leverage the following DAX measure for sales amount:

    SalesAmount_OverrideComputers =
    VAR IsComputers = SELECTEDVALUE('Product Subcategory'[product_category_new]) = "Computers"
    RETURN
    IF(
        IsComputers,
        CALCULATE(
            SUM('Sales'[SalesAmount]),
            REMOVEFILTERS('Product Subcategory')
        ),
        SUM('Sales'[SalesAmount])
    )

     

    If this helped, please mark it as the solution so others can benefit too. And if you found it useful, kudos are always appreciated.

    Thanks,

    Samson



    • han_rj's avatar
      han_rj
      Icon for Helper IV rankHelper IV

      Hi SamsonTruong thank you for responding , I have to override the above filters like country and occupation on the row Computer

      • SamsonTruong's avatar
        SamsonTruong
        Icon for Super User rankSuper User

        Hi han_rj ,

        Which column are you trying to override the visual filters for. Are you trying to override the filters on the Sales Amount column or the calculated column you created for product_category_new. 

        If you are trying to have the sales amount for computer override the visual filters, creating the DAX measure in the previous response and using that measure to replace your Sales Amount will ensure that Sales Amount for Computer will not have the visual filters applied.