Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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 @Anonymous ,

 

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 @Anonymous ,

 

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.

 

parry2k
Super User
Super User

@Anonymous 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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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
Super User
Super User

Hi @Anonymous ,

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.

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

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

@Anonymous ,

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.

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.