Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
hey guys,
I want to autoincrement my full-date filter in my daily order report. i.e. my date filter should change everyday to the previous date
for example if today is 4/14/2017 then my date filter in the report should autoincremnt to 4/13/2017
How can i achive this?
Please help me with the DAX formula...
Hi @aka,
In your scenario, did you use a slicer to fiter data? Based on my understanding, you want the date value selection in slicer to be dynamically changed everyday. That is to say, each day we open the report, the max date displayed in slicer is the date of yestoday, right? If so, please refer to @VP's advice.
If your requirement is to refresh data automatically everyday so that the report always displays data records till yestoday, this cannot be achieved by DAX. However, you can try to add a date filter in Power Query so that the imported data can be dynamically changed.
Regards,
Yuliana Gu
hi @v-yulgu-msft,
is there any other approch without using dax or creating any filters usiong DAX?
Hi @aka
I have a report that when I refresh only calculates the date table up to the current date. You can adapt this code in Query Editor -> Advanced Editor to your needs
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Date] <= Date.From(DateTime.LocalNow()))
Hope this helps.
David
Hi, where should i applly this, can you please explain me in detail.
I will be very gratefull.
Thanks
Hi @aka
Open Query Editor
Find the query for the date table in your model
Take a note of the last step name (in my case Changed Type)
Click on Advanced Editor
In the code, go to the last line and insert the code snippet I gave earlier
Replace "#Changed Type" to the name of the last step; remove the = from <=
Name your new step and also put it after the "in" (in my case "#Filtered Rows". The editor should show if you have any syntax errors - correct those and hit "OK"
This should give you a date table that only goes up to yesterday.
change "each [Date]" to "each [FullDate]"
This may be a limitation based on your data source. My date table was constructed from a list, not pulled from a database. Others may need to answer how it can be done on a SQL-based date table.
@MarcelBeug is an M specialist and may be able to get you the rest of the way.
Your FullDate is a datetime field. If you want to compare with date, then use Date.From([FullDate])
Adjust the code from @dedelman_clng to:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each Date.From([FullDate]) < Date.From(DateTime.LocalNow()))
If you are adding new column you can use
New Date = Table1[Old Date].[Date]-1
And use New column as filter
There are other options based on Where you are using filter.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
96 | |
77 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |