Forum Discussion

Kenzaobd99's avatar
Kenzaobd99
Regular Visitor
2 years ago
Solved

Need help with adding a new field parameter based on a specific category

Hello Power BI community,

I'm facing an issue with adding a new field parameter to my existing list in Power BI Country.pbix . Currently, I have a fields parameter that I use in visuals and visual filters to filter data based on the file I choose. First here's my table :  

Here is a snippet of my existing parameter: 

 

and it's used like this in visuals with diff metrics  

 

 

Now, I want to add a new parameter based on the category column from the table, meaning that when I choose Country from the filter the table gives me names with category "Country". I tried the following by specifying the category name but it didn't work when I select it from the filter it doesn't exclude the other that aren't countries: 

 

 

Could someone please help me to achieve this? Any suggestions or guidance would be greatly appreciated. 

Thank you in advance! 

  • Hi, I think what you can do is create a calculated column that will have Country categories only.

    Country = CALCULATE(VALUES(F_Param[Category]), F_Param[Category] = "Country")
    Then create a field parameter using all 3 columns.
    field_param = {
        ("Name", NAMEOF('F_Param'[Name]), 0),
        ("Category", NAMEOF('F_Param'[Category]), 1),
        ("Country", NAMEOF('F_Param'[Country]), 2)
    }
     
    If this helps to resolve your problem then please mark it as solution, Thanks!
  • In MS official documentation, it reads as follows,

    Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Learn

    ... if you want to add a new field to an existing parameter, ... and match the format shown in this example.
    
    Parameter = {
        ("Customer", NAMEOF('Customer'[Customer]), 0),
        ("Category", NAMEOF('Product'[Category]), 1),
        ("Color", NAMEOF('Product'[Color]), 2),
        ("Product", NAMEOF('Product'[Product]), 3)
    }

     

    So, your expression might not be recognizable in a field parameter table. 

2 Replies

  • Hi, I think what you can do is create a calculated column that will have Country categories only.

    Country = CALCULATE(VALUES(F_Param[Category]), F_Param[Category] = "Country")
    Then create a field parameter using all 3 columns.
    field_param = {
        ("Name", NAMEOF('F_Param'[Name]), 0),
        ("Category", NAMEOF('F_Param'[Category]), 1),
        ("Country", NAMEOF('F_Param'[Country]), 2)
    }
     
    If this helps to resolve your problem then please mark it as solution, Thanks!
  • In MS official documentation, it reads as follows,

    Let report readers use field parameters to change visuals (preview) - Power BI | Microsoft Learn

    ... if you want to add a new field to an existing parameter, ... and match the format shown in this example.
    
    Parameter = {
        ("Customer", NAMEOF('Customer'[Customer]), 0),
        ("Category", NAMEOF('Product'[Category]), 1),
        ("Color", NAMEOF('Product'[Color]), 2),
        ("Product", NAMEOF('Product'[Product]), 3)
    }

     

    So, your expression might not be recognizable in a field parameter table.