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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Aqila_Balqis
Frequent Visitor

Passing Date BETWEEN as dynamic parameters

Hello,

I have a table with DirectQuery connection to Databricks. My table only have one date column - dueDate. My end user will pick their date through date slicer that has between option. 

Aqila_Balqis_0-1698739323076.png

I've checked using DAX studio what query the slicer send to data source once it is filtered and it shows as MIN (dueDate) and MAX(dueDate):

Aqila_Balqis_1-1698739457320.png

Aqila_Balqis_0-1698741183964.png

 

I am trying to setup a multi-value dynamic parameter from date slicer. So when user choose the date, Power BI will send a custom query back to datasource with dynamic date as it parameter.

 

I was able to pass a date to dynamic parameter if its in single value, but I am currently struggling with multi-value.

 

I found this article https://blog.crossjoin.co.uk/2020/11/08/handling-multi-select-in-power-bi-dynamic-m-parameters/ and tried to do like the example provided but was clueless on how the parameter decide which is the MIN and MAX.

 

currently this is what I wrote in my sql query:

 

let 
 TextDate = DateTime.ToText(dateParam, "yyyy-MM-dd 00:00:00"),
 Source = select * from mytable where dueDate BETWEEN CAST('"& TextDate &"' AS Date) AND CAST('"& TextDate &"' AS Date)

in
 Source

//for reference of how i imagine:
//select * from myTable where dueDate BETWEEN CAST('2023-10-02' AS Date) AND CAST('2023-10-14' AS Date)

 

at first, i wrote a code for checking if its a List.Type before TextDate but I am stuck there.

 

let
    DateParamList =
        if 
        //check if its a list
        Type.Is(
            Value.Type(dateParam),
            List.Type
        ) then
        //if its a list 
        let
        //i stuck here because i dont know how to make it as min max from the list. 

 

 

Hope my explanation is clear enough. Please help me with this, I have been stuck for one week 😭

 

1 REPLY 1
miTutorials
Super User
Super User

Please see the below tutorial, i guess this is what you are looking for.

 

Setup Dynamic Parameters to Filter data in your PowerBI Report | MiTutorials - YouTube

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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