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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to: create logical filter for multiple columns

Hello,

 

I am looking for solutions to create a customized logical filter in PowerBi.

To be specific, I have columns of create_date and end_date which imply the active subscription time for that member.

The most ideal output is to create buttons called such as Q1 2021/ Q2 2021 etc. so that once I click on the filter, I am able to trace back the active subscription records in the past.

 

Thank you in advance!

date.PNG

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

you can try this,

-

1. create a calendar table, put column YQ into slicer, 

vxiaotang_0-1631612445504.png

2. then create the measure to filter the table,

Measure = 
    var _selectedDate=CALCULATE(MAX('calendar'[Date]),ALLSELECTED('calendar'[Date]))
return 
    IF(ISFILTERED('calendar'[YQ]),IF(MIN('Table'[create_date])<=_selectedDate&&MIN('Table'[end_date])>=_selectedDate,1,0),1)

show items when the value is 1,

vxiaotang_1-1631612556255.png

result

vxiaotang_3-1631612620754.pngvxiaotang_4-1631612638529.png

if you want to filter "Q2 2021" for create_date <= "2021-06-30" OR end_date>= "2021-06-30" , just change "&&" to "||".

 

 

 

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

you can try this,

-

1. create a calendar table, put column YQ into slicer, 

vxiaotang_0-1631612445504.png

2. then create the measure to filter the table,

Measure = 
    var _selectedDate=CALCULATE(MAX('calendar'[Date]),ALLSELECTED('calendar'[Date]))
return 
    IF(ISFILTERED('calendar'[YQ]),IF(MIN('Table'[create_date])<=_selectedDate&&MIN('Table'[end_date])>=_selectedDate,1,0),1)

show items when the value is 1,

vxiaotang_1-1631612556255.png

result

vxiaotang_3-1631612620754.pngvxiaotang_4-1631612638529.png

if you want to filter "Q2 2021" for create_date <= "2021-06-30" OR end_date>= "2021-06-30" , just change "&&" to "||".

 

 

 

Best Regards,

Community Support Team _Tang

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

Ashish_Mathur
Super User
Super User

Hi,

Using the M code technique here, for each ID, create one row per month between (and including) the strt date and end date.  So via this technique, all dates will now appear in a single column.  Create a Calendar Table and build a relationship from the Date column of your base data table to the Date column of your Calendar Table.  In the Calendar Table, write calculated column formulas to extract Year, Month Name, Month number and Quarter.  Sort the Month name by the Month number.  To your visual, drag any date dimension from the Calendar Table.

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hello Ashish,


I appreciate your response! However, I think your solution does not fit my scenario.


Specifically, I would like to have a button called "Q1 2021" which filters the date range as create_date <= "2021-03-31" and end_date>= "2021-03-31", "Q2 2021" for create_date <= "2021-06-30" and end_date>= "2021-06-30", etc.

Thank you!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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