cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
appnalytica
Regular Visitor

Filtering by Calculated Column Tenure Not Incluing All Levels

Hello All,

 

I am new to Power BI and I am struggling to achieve a filter/slicer, and here is the story:

 

We are using power bi desktop october 2020 since the platform we are using only allows to upload these pbx report/dashboards.

 

We have a table that includes the tenure of the employees on days, so I created a calculated column that label them as follows:

 

Note: The calculated column is just a string as showin in the example dax:

 

Demo.png

 

The problem I have is that the calculated column is somehow overwriting the labels, so for example if I choose <30 it works well, if I choose <60 will include only those from between >= 30 and <60. So the main problem is that higher selections are not including lower ones.

 

If I want to get all those <120 I must check <120, <90, <60, <30 together. So my question is if there is a way to include lower tenure, <60 include <30 or <90 include <60 and <30 as well. so If I finally select just the <120 option on the slicer it includes <120, <90, < 60 and <30 without having to select all of them.

 

Please let me know if this makes sense and if I explained myself.

 

Thanks in advance to all!

 

 

4 REPLIES 4
v-kkf-msft
Community Support
Community Support

Hi @appnalytica ,

 

Has your problem been solved? If it is solved, please mark a reply which is helpful to you.

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

 

Best Regards,
Winniz

Greg_Deckler
Super User
Super User

@appnalytica Create your slicer table as a separate Enter Data query. Then create a measure that returns the row given the right criteria. Like:

Measure =
  VAR __Selection = MAX('Slicer'[Value])
RETURN
  SWITCH(__Selection,
    "<120",IF(SUM([Tenure])<120,1,0),
    "<90",IF(SUM([Tenure])<90,1,0)
...

@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

Hello!

 

Thanks for your really quick response I really appreciate it. I created a new table just with the values:

appnalytica_0-1631540431002.png

Then I added the slicer getting the values from that table and column and got it:

appnalytica_1-1631540469984.png

When I make a selection the circular dots appear on the corners of the visuals like it's updating but it seems it is not affecting/filtering the main table. This is the processed I followed:

1. Create new table just with the filter values <120, <90, etc.

2. Created a new slicer and used the new table column as the values for the slicer which gave me this:

appnalytica_2-1631540981424.png

 

3. Create the new measure on the main employee table setting up the references like this:

Measure =
VAR __Selection = MAX('Slicer'[Value]) <- This is the slicer on Main table with the values from the new table
RETURN
SWITCH(__Selection,
"<120",IF(SUM([MainTable_Tenure])<120,1,0),
"<90",IF(SUM([MainTable_Tenure])<90,1,0)

"<60",IF(SUM([MainTable_Tenure])<60,1,0)

"<30",IF(SUM([MainTable_Tenure])<30,1,0)

)

 

I am not sure if am missing something or what could be wrong I also checked the interactions and it seems it's applying but its not changing the other visuals, for example when I choose <30 show 1200, <60 1600 (1200 <30 + 400 <60) and so on.

 

Thanks again for all your help!

Hi @appnalytica ,

 

I create the following sample data:

 

vkkfmsft_0-1631753519814.png

 

Then create the measure and show items when the measure is 1.

 

Measure = 
VAR __Selection = SELECTEDVALUE('Slicer'[Value])
RETURN
SWITCH(
    __Selection,
    "<120", IF( SUM(MainTable[Tenure]) < 120, 1, 0 ),
    "<90", IF( SUM(MainTable[Tenure]) < 90, 1, 0 ),
    "<60", IF( SUM(MainTable[Tenure]) < 60, 1, 0 ),
    "<30", IF( SUM(MainTable[Tenure]) < 30, 1, 0 ),
    ">=120", IF( SUM(MainTable[Tenure]) >= 120, 1, 0 ),
    1
)

vkkfmsft_1-1631753606579.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.