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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
obuszek
Regular Visitor

How to get min and max date based on slicer selection and assign it to parameters?

Hello,

I have a SQL query in which I used parameters (I called them parMaxDate and parMinDate) according to the article https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters
I have a requirement that the user using slicer will affect the results of the query.
Is it possible to assign the maximum and minimum date from the slicer to the parMaxDate and parMinDate parameters respectively?

2 REPLIES 2
Anonymous
Not applicable

Hi @obuszek,

As the document said, this feature allows to bind filter at the source query level. But it seems only support the specific type or data sources. What type of data source are you worked on?

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Hi @Anonymous ,

I have an Oracle SQL query where the parameter is inside a subquery.
Something like this:

SELECT COUNT(1) AS CNT
FROM TEST.F_DATA F
JOIN TEST.D_DATA D ON D.DIM_ID = F.DIM_ID
JOIN
(
SELECT D.ID_ERP, MAX(D.REV_NUM) AS MAX_REV
FROM TEST.F_DATA F
JOIN TEST.D_DATA D ON D.DIM_ID = F.DIM_ID
WHERE F.DATE_ID BETWEEN @StartDate AND @EndDate
GROUP BY D.ID_ERP
) XX
ON XX.ID_ERP = D.ID_ERP
AND XX.MAX_REV = D.REV_NUM
WHERE D.STATUS = 'Closed'

 

DATE_ID has a number type. The StartDate and EndDate parameters in Power BI have a Decimal Number type.
I have two dataset (calendars) defined which have two columns (DATE_ID - type number and DATE type date). If I use one-choice filters on the page then everything works as expected.

 

I found the following articles helpful: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-dynamic-m-query-parameters and https://learn.microsoft.com/en-us/shows/mvp-azure/pass-parameter-to-sql-queries-statement-using-power-bi

 

However, I have a requirement to use a slicer (with a slider) on the DATE field (so that the user can use the DatePicker). I don't know how to pass the minimum and maximum date from the slicer to the StartDate and EndDate parameters.
Is it at all possible to do this?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

Top Kudoed Authors