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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi: Good day! I am developing a dashboard to show different maintenance events. I have a data source [a Db table], where events info are stored for last few years. I am trying to filter data with starting date as beginning of this year. So far I have my data source settings with the sql query as below.
Many thanks in advance. 🙂
Solved! Go to Solution.
Sorry this is taking so many interations. I looked back at your original post and see that the date has single quotes around the date, so those need to be added to the date concatenated onto the SQL statement. You can do it in the main query, or you can do it in the datefilter query like this
= "'" & Date.ToText(Date.AddMonths(Date.From(DateTime.LocalNow()), -6), "yyyy-MM-dd") & "'"
I will cross my fingers that this time is the one that works.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Look back at previous post, the first function was List.Dates to start making a date table (not Date.ToText). You then need to convert that list to a table (ribbon button) and add the columns you want (Month, Year, etc.).
For the slicer, are you trying to let the use pick starting date before the API calls are made? If so, then you are talking about using a parameter, saving the file as a pbit (template). The user would be prompted to enter a start date and then the data would be fetched.
If you are looking for a slicer after the data are returned, then you can use one of the columns from your new Date table.
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @mahoneypat : Thanks for your response. I tried the query from original post in the first place, but got this:
After I put a parenthesis [I tried to put it in 3 different places to make it work! :)] but I get this error:
[to answer to your q: I am using the slicer after the api call.] Thanks in advance.
My bad. Sorry. The datefilter is in text format, so you need to either use the non-text portion of that query in place of "datefilter"
Date.AddMonths(Date.From(DateTime.LocalNow()), -6)
Or wrap datefilter in Date.FromText( ).
For example on the first one, here is some M code as an example. To see how it works, just create a blank query, go to Advanced Editor, and replace the text there with the M code below.
let
Source = Date.AddMonths(Date.From(DateTime.LocalNow()), -1),
Custom1 = List.Dates(Source, Duration.TotalDays(Date.From(DateTime.LocalNow()) - Source), #duration(1,0,0,0)),
#"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Date"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}}),
#"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([Date]), type text),
#"Inserted Year" = Table.AddColumn(#"Inserted Month Name", "Year", each Date.Year([Date]), Int64.Type)
in
#"Inserted Year"
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.