Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello
I have a SQL query ,under the WHERE condition the date slicer have few conditions.How can i achieve that in power bi?Below is the query.
WHERE
(FA.CRE_DTTM) >=
CASE WHEN #PROMPT('PARAM1')# = TO_CHAR(SYSDATE , 'YYYY-MM-DD') THEN (CURRENT_DATE - 90 )
ELSE TO_DATE(#PROMPT('PARAM1')#, 'YYYY-MM-DD')
END
AND (FA.CRE_DTTM) <=
CASE WHEN #PROMPT('PARAM2')# = TO_CHAR(SYSDATE, 'YYYY-MM-DD') THEN (CURRENT_DATE +1)
ELSE TO_DATE(#PROMPT('PARAM2')#, 'YYYY-MM-DD') +1
END
Thanks @rajendraongole1. Can I create measure or column ?
also I need only date and cre_dttm has only date.
Hi @Anonymous you have to create a parameters in Power query editor as like PARAM1 and param2.
Try the above approach.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
In this approach it will be modifying complete data set right? I want this condition only for one report and i will be creating the parameters in data model.
Hi @Anonymous -you can achieve the date filtering logic similar to your SQL query in Power BI using parameters and Power Query Editor.
Create two parameters in Power BI, one for PARAM1 and another for PARAM2. Make sure to set the data type of these parameters to Date/Time and configure the default values as required.
In your power query editor, below steps should be added
Param1 = DateTime.FromText(Text.From(Date.From(DateTime.LocalNow())),
Param2 = DateTime.FromText(Text.From(Date.From(DateTime.LocalNow()))),
FilteredRows = Table.SelectRows(Source, each ([CRE_DTTM] >= if [CRE_DTTM] = Param1 then Date.AddDays(DateTime.LocalNow(), -90) else Param1
and [CRE_DTTM] <= if [CRE_DTTM] = Param2 then Date.AddDays(DateTime.LocalNow(), 1) else Param2))
This script will filter the rows based on the parameters PARAM1 and PARAM2. It compares the values of [CRE_DTTM] with the parameters and applies the filtering logic accordingly.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |