March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I need to pass datetable with a column bind to startdate parameter and passed to sql query in direct mode like
select a,max(b)b,max(c)c,max(ac)ac,max(dt)dt from tabl1
join (select ac,max(c) from tabl2 group by ac)tabs on tabl1.ac= tabl2.ac
where dt between @datefrom and @dateto
group by a
i'm create 2 calander date tables and 2 parameters start date and end date, and biniding table colmns to these parameters and passing them in query editor in m script - thats is cool!
now i want to create a bookmarks for
I have added datefrom and dateto variable so that I can pass value from power bi to sql query
Thanks for ur response! But we don't have relative date option available. Additionally we are passing dates on sql query then using group by. Means my filter is applicable on query level not power bi level, there the current method will give wrong results. As we are getting max of dt in above query, there could be multiple dates but at power bi we are getting max of it. Any other alternative plz Im bagging my head
Hi @Asmasm -you can achieve dynamic date range filtering (e.g., Year-to-Date, Last Year, Last Quarter, As of Today) by creating measures with dynamic date calculations instead of relying solely on parameters.
Create a disconnected table with the name Date Range Selection that contains your date range options:
DateRangeOptions =
DATATABLE(
"Date Range", STRING,
{
{"Year-to-Date"},
{"Last Year"},
{"Last Quarter"},
{"As of Today"}
}
)
Now, Create a new measure to display the filtered data based on the selected date range option
DynamicSales =
SWITCH(
SELECTEDVALUE('DateRangeOptions'[Date Range]),
"Year-to-Date", [Sales_YTD],
"Last Year", [Sales_LastYear],
"Last Quarter", [Sales_LastQuarter],
"As of Today", [Sales_AsOfToday],
BLANK()
)
For each date range option, select the corresponding value in the Date Range Selection slicer.
Go to the View tab > Bookmarks and add a new bookmark for each selection (e.g., YTD, Last Year, Last Quarter, As of Today).
Add buttons to your report (e.g., for Year-to-Date, Last Year, Last Quarter, As of Today).
Set the Action property of each button to the corresponding bookmark, so users can switch between date ranges by clicking the buttons.
Or
If you’re working within Power BI Service or Power BI Desktop with an active connection, you could also explore using the Relative Date Slicer.
Hope this works.
Proud to be a Super User! | |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
105 | |
99 | |
64 | |
54 |