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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft ,

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-powe...

 

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.