Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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 :
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.
Solved! Go to Solution.
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
I hope this helps. Please give a thumbs up and mark as solved if it does, thanks!
@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 @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
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
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:
country | flag1 | flag2 | Revenue |
Germany | Yes | 10 | |
Germany | Yes | No | 15 |
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:
country | Revenue |
Germany | 25 |
If "No" is selected "Flag2" will be enforced and we have Revenue as 15 i.e the below table will be displayed:
country | Revenue |
Germany | 15 |
Can you please help.
@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
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.
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!
User | Count |
---|---|
73 | |
72 | |
39 | |
25 | |
23 |
User | Count |
---|---|
96 | |
93 | |
51 | |
43 | |
42 |