Forum Discussion

AnupTandale's avatar
AnupTandale
New Member
1 year ago
Solved

How to Filter Date/Time Columns in DirectQuery Mode Using M Query Parameters?

I am working with a table in DirectQuery mode in Power BI, and I need to filter a column of type `date/time` using slicers. Currently, the parameters `startDate` and `endDate` are of type `date` an...
  • bhanu_gautam's avatar
    1 year ago

    AnupTandale , Try using

     

    let
    startDateText = Date.ToText(startDate, "yyyy-MM-dd"),
    endDateText = Date.ToText(endDate, "yyyy-MM-dd"),
    KustoParameterDeclareQuery = Text.Combine(
    {
    "declare query_parameters(",
    "startTime:datetime = datetime(", startDateText, " 00:00:00), ",
    "endTime:datetime = datetime(", endDateText, " 23:59:59)); "
    })
    in
    KustoParameterDeclareQuery

     

    The startDate and endDate parameters are kept as date type, and the datetime values are constructed within the query using Date.ToText to format the dates and append the time portion.