The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Must be very simple but cannot get it to work....
Have this simple table:
Now I want to make a slicer that shows me only the periods where there are actuals.
Or switch the other side to show also the zeros.
Was trying with If / Calculate and Sum but can only get a Yes (active month) or No (zeros) when I put the calculated field in the vsiual.
But I want it in a slicer.
Solved! Go to Solution.
Hi @rpinxt ,
Sorry for the delay.
I tried using "SUM ( SAP_Data[ActualsLC] )" instead of "SELECTEDVALUE ( SAP_Data[ActualsLC] )" and it works.
ActivitySelection =
VAR selection =
SELECTEDVALUE ( Activity[Activity] )
RETURN
SWITCH (
selection,
"Yes", IF ( SUM ( SAP_Data[ActualsLC] ) > 0, 1, 0 ),
"No", IF ( SUM ( SAP_Data[ActualsLC] ) = 0, 1, 0 ),
1
)
This is because the [ActualsLC] here is a sum value and not a single value.
Pbix as attachment.
Best Regards,
Jay
Hi @rpinxt ,
Use enter data feature to create a slicer table:
Then create a measure like below and add it to visual filter.
Measure =
SWITCH (
SELECTEDVALUE ( slicer[slicer] ),
"yes", IF ( SELECTEDVALUE ( 'Table'[ActualsLC] ) > 0, 1, 0 ),
"no", IF ( SELECTEDVALUE ( 'Table'[ActualsLC] ) = 0, 1, 0 ),
1
)
Best Regards,
Jay
Very Nice one @Anonymous but also this one I cannot not use in a simple slicer apparently....
What am i doing wrong?!
This is my measure:
I also cannot put this measure in my filters...just does not take it...
What is different in my measure, table setup??
Hi @rpinxt ,
The measure should be added to the table visual not the slicer visual.
If it still doesn't work, please share the pbix file.
Best Regards,
Jay
Ok @Anonymous , somehow now was able to put ActivitySelection measure to the visual filter as in your screenshots.
But you also have a slicer there with yes and no.
How did you then make that?
Because when I make a slicer and want to put the measure in it will not take it.
*EDIT*:
Duhhh...my bad!
Had to use the normal Activity not the measure....😣
Just not getting it to work...
When I select Yes all is gone....hmmm have to check it out more
Hi @rpinxt ,
The slicer is used to return different value for the ActivitySelection measure.
Ok thanks for the explanation!
But something must be off then.
My formula:
With nothing selected in slicer:
With No selected:
With Yes selected:
The filter in the visual:
The measure shows always 1 and I think my logic is also the wrong way around?
Would expect 1 when there is a value.
How would I do that?
Tried dragging and dropping it on this reply but says .pbix is not supported.
Never shared a file before via this site.
Hi @rpinxt ,
Do you have google drive or onedrive? You could upload the pbix file and share the download link here.
Best Regards,
Jay
Doubt a bit if this will work.
Link from my onedrive but not sure if it will work....
Maybe more luck with my google drive link:
https://drive.google.com/file/d/1m1_Q1feoHOJMacreUPQRv_6gLBGf05so/view?usp=sharing
Hi @rpinxt ,
Sorry for the delay.
I tried using "SUM ( SAP_Data[ActualsLC] )" instead of "SELECTEDVALUE ( SAP_Data[ActualsLC] )" and it works.
ActivitySelection =
VAR selection =
SELECTEDVALUE ( Activity[Activity] )
RETURN
SWITCH (
selection,
"Yes", IF ( SUM ( SAP_Data[ActualsLC] ) > 0, 1, 0 ),
"No", IF ( SUM ( SAP_Data[ActualsLC] ) = 0, 1, 0 ),
1
)
This is because the [ActualsLC] here is a sum value and not a single value.
Pbix as attachment.
Best Regards,
Jay
Thanks! @Anonymous
It works now indeed.
I will be studying this file to understand exactly how it works (most of it I already understood)
Thanks for all your time and effort!
Ps: how did you add the pbix as an attachement??
I could not find that option on my side.
Hi @rpinxt ,
It is simple indeed.
1) Add a flag to your table to check if the actuals column has a value or not. If it is 0 then 0 else 1. Name this "ValueFlag"
2) Add your period and actuals values into a table and add valueflag as a slicer. Set value of valueflag as 1.
When you select 1, it wil show you values
When you deselect the slicer, it shows all values
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
This is an interesting one but somehow does not work for me:
In the table it works.
But in the slicer nothing shows up.
And when in the filer I cannot put in on advanced filtering.
Also..would this only work with 0 and 1?
Not like with Yes/No or On/Off ?
Hi @rpinxt ,
Please use the slicer visual that I've circled in red in the screenshot below
You can change the calculated value to show whatever you feel like. I've chosen 0/1. Just be sure to set the filter on the slicer using the same value ( I set it to 1 in my case, you can set it to Yes or On etc depending on the values you choose)
Kind regards,
Rohit
Please mark this answer as the solution if it resolves your issue.
Appreciate your kudos! 🙂
ah only with the standard slicer? Hmmm...but i cannot put the measure that I made to that slicer at all....
Is there something wrong with my formula? It is working in the table:
Hi @rpinxt ,
ValueFlag needs to be a calculated column NOT a measure. Only then can you use it in a slicer.
Kind regards,
Rohit
Hi,
You can create a new column that says if your actuals are Zero or not