Forum Discussion
How to create a parameter with dynamic Date query list
- 3 years ago
We're getting there 😄
You can't compare date and datetime types.
Change the StartOfCurrentMonth query to...
// StartOfCurrentMonth let Source = Date.StartOfMonth( DateTime.FixedLocalNow() ) in Source
Hi RL_171,
I think it'll be pretty easy to solve but I need a little more detail.
Can you post some sample data from the source system? (obfuscate anything sensitive)
Is the source data at the same grain e.g. is it daily or monthly?
Do you have a date table in your model?
- RL_1713 years agoFrequent Visitor
Thanks for responding to my question. The source data looks exact the same, i.e. in Date format but shows first date of each month. The only differenct between the source data and the PBI data is that the source data has more rows (past dates) while the PBI should show the current and future dates only. I have built a date table in PBI model and connected with the opportunity table like this:
Date =ADDCOLUMNS(CALENDARAUTO(),"Year", Year([Date]),"Month", FORMAT([Date],"mmmm"),"Month Number", MONTH ([Date]),"Quarter", FORMAT([Date],"\QQ"),"Quarter Number", QUARTER([Date]))- KNP3 years agoSuper User
Ok, based on that info, I think a measure like this could do what you want.
Result = var _today = TODAY() var _year = YEAR(_today) var _month = MONTH(_today) var _futureMonths = 12 var _filter = FILTER( data, data[Start of Month] >= DATE(_year,_month,1) && data[Start of Month] <= DATE(_year,_month + _futureMonths,1) ) RETURN CALCULATE([_Value], _filter)I've attached a sample PBIX for you to look at. It's a little dependent on the complete model.
Let me know how you get on.
(I'm not sure about the CALENDARAUTO and interaction with this, I don't use it. If you're going to build your date table with DAX, I'd recommend using CALENDAR)
- RL_1713 years agoFrequent Visitor
Yes, magic happens! This is the result I want. Question: as there are multiple years of data saved in the database, when I open the PBI report, I just want to load the filtered data into the report. Can I apply this measure to parameter when transforming data?