Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Removing Nulls from Only One Parameter Field

Hello,

I have the following code for a Field Parameter I created in Power BI: 

Production Role = {
("Product Engineer", NAMEOF('Assignment'[Product Engineer]), 0),
("Intern", NAMEOF('Assignment'[Intern]), 1),
("Product Developer", NAMEOF('Assignment'[Product Developer]), 2)
}

On the visual side of things, I have a table created with information based off of these three Production Roles, and have it set up so that you can click between the three Production Roles and it will update the table and cards I have on the front end based off of that specific role. The issue I am having is that I don't want null names to show up for Intern because the blank names will influence the totals for different metrics I have set up in the table and cards (due to some assignments having a Product Developer or Product Engineer but no Intern. Every assignment has both a Product Developer and Engineer, but it is much more rare to have an Intern). So I want to not show the information for null Interns, but ONLY if the Production Role is Intern. Otherwise, I want the nulls to stay so that if there is an Product Developer or Product Engineer on an Assignment but not an Intern, those Assignments that don't have an Intern will still show up when I click on either the Product Developer or Product Engineer and give them their correct metric numbers on the table and cards. Any ideas?

  • Hi Anonymous 
    To achieve a goal you can take these few steps :

    1 With power query replace "blanks " with null (until you do it the engine of pbi does not recognize these cells as blanks.

    2. After creating field parameters add to the parameters table another column with the parameter name to have an ability to create conditions with it 

    3 . Create a flag measure that will check which parameter was selected and if it is blank:

    test_intern = if(SELECTEDVALUE('Parameter'[Test parametr])="Intern" && ISBLANK(max('Table'[Intern])),1,0)

    4. Use this measure to filter the visual

    pbix is attached

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

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ritaf1983   Here is an example of the table named "Assignment."

      AssignmentProduct EngineerProduct DeveloperInternTotal ProducedTotal Sold
      232451Mannie JacobsonCarlie Abrams 341238
      232452Jerrie VinlandJose Martinez 12199
      232453Connie BanditMickie BarrettMariah Ham645561
      232454Mannie JacobsonJose Martinez 222106
      232455Connie BanditCarlie Abrams 9988
      232456Mannie JacobsonCarlie AbramsMariah Ham561

      498

       

      Here is what the Field Parameter looks like, a standard field parameter based off of fields in the assignment table.

      Production RoleParameter FieldsParameter Order
      Product Engineer'Assignment'[Product Engineer]0
      Product Developer'Assignment'[Product Developer]1
      Intern'Assignment'[Intern]2


      Now, this is what the tables look like on the front end, imagining that each table pops up when you click on the role tile based on the parameter, and the first row in the table is the role type.

      Product EngineerTotal ProducedTotal Sold
      Mannie Jacobson1124842
      Connie Bandit744649
      Jerrie Vinland12199
      TOTAL19891590

       

      Product DeveloperTotal ProducedTotal Sold
      Carlie Abrams1001824
      Jose Martinez343205
      Mickie Barrett645561
      TOTAL19891590

       

      InternTotal ProducedTotal Sold
       783531
      Mariah Ham12061059
      TOTAL19891590


      So here you can see that nulls are pulling in for Interns, even though I only want the TRUE intern totals. The other two charts are perfectly fine as there are no nulls and nothing is skewing the data, so we want to make sure the assignments that have interns that are null are still pulling product developers and engineers so that their totals are correct. But imagine if there were many many more rows and more interns, they could see their personal totals, but managers would not be able to see the production of interns as a whole. So I want to be able to have this parameter set up where you can click on a slicer role tile and switch between the three roles to see the three charts I have put aboce, but only have to make the one chart thanks to parameters. But I want to take out null role names so that the totals are correct.

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

        Hi Anonymous 
        To achieve a goal you can take these few steps :

        1 With power query replace "blanks " with null (until you do it the engine of pbi does not recognize these cells as blanks.

        2. After creating field parameters add to the parameters table another column with the parameter name to have an ability to create conditions with it 

        3 . Create a flag measure that will check which parameter was selected and if it is blank:

        test_intern = if(SELECTEDVALUE('Parameter'[Test parametr])="Intern" && ISBLANK(max('Table'[Intern])),1,0)

        4. Use this measure to filter the visual

        pbix is attached

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