Forum Discussion
Filtering Contracts based on expiring Period by months
Dear Colleagues,
I would like to create an IF-parameter slicer button with three categories, allowing users to filter contracts based on their expiry periods:
Contracts Expiring in Less Than 3 Months (Red)
- When selected, the table will display all contracts expiring within the next 3 months from today.
Contracts Expiring in Less Than 6 Months (Yellow)
- When selected, the table will display all contracts expiring within the next 6 months from today.
Contracts Expiring in Less Than 12 Months (1 Year) (Green)
- When selected, the table will display all contracts expiring within the next 12 months from today.
Show All Contracts
- If no button is selected, the table will display all contracts without any expiry filter.
Please attach PBIX file:
https://drive.google.com/file/d/1dNSckQUbymKccqY1TsvV83TNgoz3gdN7/view?usp=sharing
see reference below.
https://www.youtube.com/watch?v=N-3bpmyuf2c
Thanks for your help
Hi vtech007, have you tried to create a calculated column and then use it as a filter?
Expires In = VAR CurrentDate = TODAY() VAR Expiration_Date = YourTable[Contract_End_Date] VAR MonthsDiff = DATEDIFF(CurrentDate, Contract_End_Date, MONTH) RETURN SWITCH( TRUE(), MonthsDiff <= 3, "Expires in the next 3 months", MonthsDiff <= 6, "Expires in the next 6 months", MonthsDiff <= 12, "Expires in the next 12 months" )You can then activate the select all option from your slicer
If it helped you please mark it as solution
2 Replies
- vtech007Frequent Visitor
MattiaFratello Thank you so much for the solution. kudos to you
- MattiaFratelloSuper User
Hi vtech007, have you tried to create a calculated column and then use it as a filter?
Expires In = VAR CurrentDate = TODAY() VAR Expiration_Date = YourTable[Contract_End_Date] VAR MonthsDiff = DATEDIFF(CurrentDate, Contract_End_Date, MONTH) RETURN SWITCH( TRUE(), MonthsDiff <= 3, "Expires in the next 3 months", MonthsDiff <= 6, "Expires in the next 6 months", MonthsDiff <= 12, "Expires in the next 12 months" )You can then activate the select all option from your slicer
If it helped you please mark it as solution