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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TusharGaurav
Helper III
Helper III

How to create a boolean slicer in power bi desktop

Hi Experts,

 

I am recreating a report from Quicksight where a user defined filter "UDF" is present having "Yes/No" values.
There is a calculation used using this filter as below:

ifelse(

UDF='No',{Flag1},
UDF='Yes',{Flag2},
' ')

Here Flag1 is a column in my table having "No"as value and  Flag2 is a column in my table having "Yes"as value.

So when "No" is selected , the report visuals will show value as per flag1 and if "Yes" is selected the report visuals will show value as per Flag2.

I have tried using using boolean parameter by creating a table as below :

Boolean Parameter =
   DATATABLE(
        "Option", STRING,
        "Value", BOOLEAN,
        {
            { "Yes", TRUE },
            { "No", FALSE }
        }
   )

But I dont know how to link the parameter with the flags and hence the corresponding values used in my visuals.

Can you please help.

2 ACCEPTED SOLUTIONS
wardy912
Responsive Resident
Responsive Resident

Hi @TusharGaurav 

Create a table to use as your slicer (Modeling - New Table)

 

SlicerFlag = DATATABLE("FlagChoice", STRING, {{"Yes"}, {"No"}})

 

Then, add the following measure to your data table


Selected Revenue = 
VAR SelectedFlag = SELECTEDVALUE(SlicerFlag[FlagChoice])
RETURN
    SWITCH(
        SelectedFlag,
        "Yes", CALCULATE(SUM('Table'[Revenue]), 'Table'[Flag1] = "Yes"),
        "No", CALCULATE(SUM('Table'[Revenue]), 'Table'[Flag2] = "No"),
        BLANK()
    )

 

Now add country and your 'selected revenue' measure to a table visual, and add the 'FlagChoice' column from your slicer table to a slicer visual


wardy912_0-1753348157637.pngwardy912_1-1753348181554.png

I hope this helps. Please give a thumbs up and mark as solved if it does, thanks!

 

View solution in original post

@TusharGaurav Hey ,
I will follow below steps

Step 1 : Create a slicer table using below dax
BooleanParameter = DATATABLE( "Option", STRING, { { "Yes" }, { "No" } } )

steps 2: Drag Option to a slicer.

Step3 : Create a new measure using below dax
SelectedRevenue =
VAR SelectedOption = SELECTEDVALUE(BooleanParameter[Option])

RETURN
SWITCH( TRUE(), SelectedOption = "Yes",
CALCULATE(SUM(YourTable[Revenue]), YourTable[Flag1] = "Yes"),
SelectedOption = "No",
CALCULATE(SUM(YourTable[Revenue]), YourTable[Flag2] = "No"),
BLANK() )
 
Step 4: drag the same measure in table viz and change slicer from slicer viz


Thanks
Harish M

If these steps help resolve your issue, your acknowledgment would be greatly appreciated.

 

 

View solution in original post

11 REPLIES 11
wardy912
Responsive Resident
Responsive Resident

Hi @TusharGaurav 

Create a table to use as your slicer (Modeling - New Table)

 

SlicerFlag = DATATABLE("FlagChoice", STRING, {{"Yes"}, {"No"}})

 

Then, add the following measure to your data table


Selected Revenue = 
VAR SelectedFlag = SELECTEDVALUE(SlicerFlag[FlagChoice])
RETURN
    SWITCH(
        SelectedFlag,
        "Yes", CALCULATE(SUM('Table'[Revenue]), 'Table'[Flag1] = "Yes"),
        "No", CALCULATE(SUM('Table'[Revenue]), 'Table'[Flag2] = "No"),
        BLANK()
    )

 

Now add country and your 'selected revenue' measure to a table visual, and add the 'FlagChoice' column from your slicer table to a slicer visual


wardy912_0-1753348157637.pngwardy912_1-1753348181554.png

I hope this helps. Please give a thumbs up and mark as solved if it does, thanks!

 

Hi Wardy,

 

Thanks for your help.

 

Thanks and Regards,

Tushar Gaurav

wardy912
Responsive Resident
Responsive Resident

In order for me to assist further, i'll need an example of the dataset and more details of the desired outcome please

Hi Wardy,

Please refer the dataset below:

countryflag1flag2Revenue
GermanyYes 10
GermanyYesNo15

So I need to have a Slicer having "Yes/No".

If "Yes" is selected "Flag1" will be enforced and we have Revenue as 25 i.e the below table will be displayed:

countryRevenue
Germany25

If "No" is selected "Flag2" will be enforced and we have Revenue as 15 i.e the below table will be displayed:

countryRevenue
Germany15

Can you please help.

Hi @wardy912 ,

Can you please help.

 

Thanks and Regards,

Tushar Gaurav

@TusharGaurav Hey ,
I will follow below steps

Step 1 : Create a slicer table using below dax
BooleanParameter = DATATABLE( "Option", STRING, { { "Yes" }, { "No" } } )

steps 2: Drag Option to a slicer.

Step3 : Create a new measure using below dax
SelectedRevenue =
VAR SelectedOption = SELECTEDVALUE(BooleanParameter[Option])

RETURN
SWITCH( TRUE(), SelectedOption = "Yes",
CALCULATE(SUM(YourTable[Revenue]), YourTable[Flag1] = "Yes"),
SelectedOption = "No",
CALCULATE(SUM(YourTable[Revenue]), YourTable[Flag2] = "No"),
BLANK() )
 
Step 4: drag the same measure in table viz and change slicer from slicer viz


Thanks
Harish M

If these steps help resolve your issue, your acknowledgment would be greatly appreciated.

 

 

Hi Harish,

 

Thanks for your help.

 

Thanks and Regards,

Tushar Gaurav

TusharGaurav
Helper III
Helper III

Hi Wardy,

 

Thanks for your response.

Actually I need to know how to link measure with my visual.

For example in my Bar visual , I am showing Country and revenue. Now when "Yes" is selected revenue corresponding to "Flag1" will be displayed and when "No" is selected revenue corresponding to "Flag2" will be displayed.

Can you please help.

 

No problem @TusharGaurav 

 

I think you need to use field parameters, this youtube video will explain it in detail.

Fields Parameter in Action I Practical Examples


Hi Wardy, 

 

Thanks for your reply.

Actually I have also tried field level parameter. But I got struck of how to use this filed level parameter in my visual where I have "Country" and revenue and I need to show value as per the dynamic slicer.

Can you please help.

wardy912
Responsive Resident
Responsive Resident

Hi @TusharGaurav 

 

 You need to add a measure, then use that measure in your visual


Selected Flag Value = 
VAR SelectedBool = 
    SELECTEDVALUE('Boolean Parameter'[Value])

RETURN
    IF(
        SelectedBool = TRUE,
        MAX('MainTable'[Flag2]),
        MAX('MainTable'[Flag1])
    )

 

I hope this helps, please give a thumbs up and mark as solved if it does, thanks!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.