Forum Discussion

realMagnusKvale's avatar
realMagnusKvale
New Member
6 months ago
Solved

Field parameter returning list

Hi y'all 🤠🐮

 

I want to make a slicer for field parameters that returns a list of column names, not one column name per slicer choice (pardon my terminology if it's wrong).

 

The first example below works just fine, but the user can choose 10 x 9 x 8 = 10! combinations of columns, but the only two combinations that actually makes sense are column 1, ... column 5 for either orig or test.. In addition, the choice is sensitive to the order of the slicer choice, which I don't want either...

 

Can this be done? Any solution using bookmarks is not really interesting, that strikes me as terrible engineering, especially from a maintenance perspective 👀

 

Examples:

some_field_parameters = {
    ("Column 1, Orig", NAMEOF('table'[column_1_orig]), 0),
    ("Column 2, Orig", NAMEOF('table'[column_2_orig]), 1),
    ("Column 3, Orig", NAMEOF('table'[column_3_orig]), 2),
    ("Column 4, Orig", NAMEOF('table'[column_4_orig]), 3),
    ("Column 5, Orig", NAMEOF('table'[column_5_orig]), 4),
    ("Column 1, Test", NAMEOF('table'[column_1_test]), 5),
    ("Column 2, Test", NAMEOF('table'[column_2_test]), 6),
    ("Column 3, Test", NAMEOF('table'[column_3_test]), 7),
    ("Column 4, Test", NAMEOF('table'[column_4_test]), 8),
    ("Column 5, Test", NAMEOF('table'[column_5_test]), 9)
}

my_dream_field_parameters {
    ("Orig", (
				NAMEOF('table'[column_1_orig]),
				NAMEOF('table'[column_2_orig]),
				NAMEOF('table'[column_3_orig]),
				NAMEOF('table'[column_4_orig]),
				NAMEOF('table'[column_5_orig])
			), 0),
    ("Test", (
				NAMEOF('table'[column_1_test]),
				NAMEOF('table'[column_2_test]),
				NAMEOF('table'[column_3_test]),
				NAMEOF('table'[column_4_test]),
				NAMEOF('table'[column_5_test])
			), 1)
}

 

  • Hi realMagnusKvale, you can enrich the field parameter code with extra columns to group values:

    Parameter New = {
        ("column_1_orig", NAMEOF('table'[column_1_orig]), 0, "Orig"),
        ("column_2_orig", NAMEOF('table'[column_2_orig]), 1, "Orig"),
        ("column_3_orig", NAMEOF('table'[column_3_orig]), 2, "Orig"),
        ("column_4_orig", NAMEOF('table'[column_4_orig]), 3, "Orig"),
        ("column_5_orig", NAMEOF('table'[column_5_orig]), 4, "Orig"),
        ("column_1_test", NAMEOF('table'[column_1_test]), 5, "Test"),
        ("column_2_test", NAMEOF('table'[column_2_test]), 6, "Test"),
        ("column_3_test", NAMEOF('table'[column_3_test]), 7, "Test"),
        ("column_4_test", NAMEOF('table'[column_4_test]), 8, "Test"),
        ("column_5_test", NAMEOF('table'[column_5_test]), 9, "Test")
    }

    Now, you can create a hierarchy like in the Option #1. However, it doesn't block a user from selecting some items from different groups. What you can do is to apply the Option #2 where you use 2 separate slicers: the first one forces a user to select "Orig" or "Test" group and then the second one allows to select the items. Important: the second slicer should not filter the first one (check iteraction b/w items)

    I'm attaching pbix.

    Good luck with your project! 🙂

     

3 Replies

  • Hi realMagnusKvale, you can enrich the field parameter code with extra columns to group values:

    Parameter New = {
        ("column_1_orig", NAMEOF('table'[column_1_orig]), 0, "Orig"),
        ("column_2_orig", NAMEOF('table'[column_2_orig]), 1, "Orig"),
        ("column_3_orig", NAMEOF('table'[column_3_orig]), 2, "Orig"),
        ("column_4_orig", NAMEOF('table'[column_4_orig]), 3, "Orig"),
        ("column_5_orig", NAMEOF('table'[column_5_orig]), 4, "Orig"),
        ("column_1_test", NAMEOF('table'[column_1_test]), 5, "Test"),
        ("column_2_test", NAMEOF('table'[column_2_test]), 6, "Test"),
        ("column_3_test", NAMEOF('table'[column_3_test]), 7, "Test"),
        ("column_4_test", NAMEOF('table'[column_4_test]), 8, "Test"),
        ("column_5_test", NAMEOF('table'[column_5_test]), 9, "Test")
    }

    Now, you can create a hierarchy like in the Option #1. However, it doesn't block a user from selecting some items from different groups. What you can do is to apply the Option #2 where you use 2 separate slicers: the first one forces a user to select "Orig" or "Test" group and then the second one allows to select the items. Important: the second slicer should not filter the first one (check iteraction b/w items)

    I'm attaching pbix.

    Good luck with your project! 🙂

     

  • Hi realMagnusKvale 

    Can you please explain this?

     combinations of columns, but the only two combinations that actually makes sense are column 1, ... column 5 for either orig or test.. In addition, the choice is sensitive to the order of the slicer choice, which I don't want either...

    Also, Power BI does not preserve the order in which selections are made. The column order is determined by the order column in the field parameter.

    • realMagnusKvale's avatar
      realMagnusKvale
      New Member

      danextian, yes:

       

      1.

      In the first example, the user can choose e.g. Column 1, Orig and Column 3, Test. In my case, that's a non sensical choice. I'd like to force the user to make one of two choices, "Orig" or "Test", each of which returns a list of five column names.

       

      2.

      I just checked, and wheter I choose 5, 3, ..., 1 or 1, 2, ..., 5 makes a difference: The matrix and bar chart that use the field parameters in question depend on the order of the choice made by the user, I can see it happen.. I'd like that not to be the case.. I could consider taking a screenshot, but I'd have to remove a lot of information, so I don't share anything that I'm not supposed to.