cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
commodity_check
Helper II
Helper II

How to set a slicer with "yes" option if column contains value & "no" option if column does not

Hi all,

 

I have multiple columns representing services which have prices and null values. A null value means that the company does not provide the service. See Example table below. I want to make a simple slicer for all services in which I can select "True" or "False" (see second table, which is a mockup for my slicer). If I select True for Service 1 for instance, it shows all companies which have a price. If I select false, I want to see all the companies with null values. 

 

The only way I can come up with is by creating an extra column in Power Query for every service and use the formula:

if value <> null then "TRUE" else "FALSE".

But this results in a lot of extra columns and thus extra loading time. There has to be a way in which I can slice and dice in an easier way?

 

 Service 1Service 2
Company A €       1.50 null 
Company B null  null 
Company C €       2.00 €       3.00
Company D €       3.00 €       5.00

 

commodity_check_0-1622470779414.png

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @commodity_check ,

 

If you don't want to create a new column. You can create a simple table by entering data.

v-stephen-msft_0-1622703451125.png

 

Based on my test, the returned value must be Company or Service. If it is changed to Value, there will be an error.

Company1 =
SWITCH (
    SELECTEDVALUE ( 'Table (2)'[T/F] ),
    "True", CALCULATE ( MAX ( 'Table'[Company] ), FILTER ( 'Table', [Value] <> BLANK () ) ),
    "False", CALCULATE ( MAX ( 'Table'[Company] ), FILTER ( 'Table', [Value] = BLANK () ) )
)

v-stephen-msft_3-1622704041222.pngv-stephen-msft_4-1622704046481.png

 

 

 

Best Regards,

Stephen Tao

 

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

 

View solution in original post

5 REPLIES 5
v-stephen-msft
Community Support
Community Support

Hi @commodity_check ,

 

If you don't want to create a new column. You can create a simple table by entering data.

v-stephen-msft_0-1622703451125.png

 

Based on my test, the returned value must be Company or Service. If it is changed to Value, there will be an error.

Company1 =
SWITCH (
    SELECTEDVALUE ( 'Table (2)'[T/F] ),
    "True", CALCULATE ( MAX ( 'Table'[Company] ), FILTER ( 'Table', [Value] <> BLANK () ) ),
    "False", CALCULATE ( MAX ( 'Table'[Company] ), FILTER ( 'Table', [Value] = BLANK () ) )
)

v-stephen-msft_3-1622704041222.pngv-stephen-msft_4-1622704046481.png

 

 

 

Best Regards,

Stephen Tao

 

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

 

View solution in original post

parry2k
Super User III
Super User III

@commodity_check the best would be to unpivot your table and then add the True/False column. To unpivot, select the Company column, right-click and then unpivot other columns. It will give you two columns Attribute and Value and now you can add  True/False column.

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

In visualization, now you have the option to select service and also true/false for that service.






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





ERD
Solution Sage
Solution Sage

Hi @commodity_check ,

My first suggestion for such case would be to unpivot columns with services. In this case you will have just 2 columns: service name and value. Other part would be very easy in this case.

ERD_0-1622475863064.png

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

But this way if I create a slicer I still will get a lot of options (null, 2 euros, 3 euro's) for a service, while I only wish to see True/False

@commodity_check ,

True/False is the "other part".

After unpivoting columns you can create a new custom column with the logic you need:

Add column - Custom Column:

ERD_0-1622542859361.pngERD_1-1622542874047.png

If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors