Forum Discussion
Webscraping - Change the date filter
- Anonymous1 year ago
Hi EusebioJr_BR ,
If you are trying to always automatically query data 30 days forward from the current day's date, you can try the following M code:= Table.SelectRows(#"Changed Type", each [Date] >= Date.AddDays(DateTime.Date(DateTime.LocalNow()), -30) and [Date] <= DateTime.Date(DateTime.LocalNow()))
Here is the whole M code in the Advanced Editor:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdQ9igMxEEThuyg2jKpb85c6MTiadDFz/2vsJq4GvQ3Fi/Sh0ufTXs/rff20R1NftC/RY/wdxtruxxQ3x8G4OibjcAzGdBRjOHZGfWOejN3xQDzddrTDbUMzT5LHOkkd4yRxbJO0MU2SxjL5j8y3xQRzLmmXOOYWdokdzS6xodklVjS7xECzSySaXSLQ7BJCs0t0NLsILmEXwUV2EVxkF8Gl5iS41JoElxqT4FJbElxqSoJLLUlwqSGBpWYEFaPAxCQQMQg86nOZS41nLvVE8Mp92Xbfvw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Moeda = _t, Date = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Moeda", type text}, {"Date", type date}, {"Value", Int64.Type}}), FilteredRows = Table.SelectRows(#"Changed Type", each [Date] >= Date.AddDays(DateTime.Date(DateTime.LocalNow()), -30) and [Date] <= DateTime.Date(DateTime.LocalNow())) in FilteredRows
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi EusebioJr_BR ,
Assuming this is your datasheet:
You can use this DAX to create a calculated table called Calendar:
Calendar = CALENDAR(MINX(ALL('Table'), 'Table'[Date]), TODAY())
Then create relationship:
Now you can use the Calendar table to create a slicer:
Every day when you reopen or refresh the report, the right side of the slicer will automatically change to the current day's date.
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Sorry, I wasn't clear in my question. I need the query to bring the current date. Currently when I update the information the query brings me information from the last 30 days. For example: from 09/01 to the present day. Below is the example of how the base comes (always from the last 30 days). In short: I need to lock the start date and the current date always to today.
- Anonymous1 year agoNot applicable
Hi EusebioJr_BR ,
If you are trying to always automatically query data 30 days forward from the current day's date, you can try the following M code:= Table.SelectRows(#"Changed Type", each [Date] >= Date.AddDays(DateTime.Date(DateTime.LocalNow()), -30) and [Date] <= DateTime.Date(DateTime.LocalNow()))
Here is the whole M code in the Advanced Editor:let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdQ9igMxEEThuyg2jKpb85c6MTiadDFz/2vsJq4GvQ3Fi/Sh0ufTXs/rff20R1NftC/RY/wdxtruxxQ3x8G4OibjcAzGdBRjOHZGfWOejN3xQDzddrTDbUMzT5LHOkkd4yRxbJO0MU2SxjL5j8y3xQRzLmmXOOYWdokdzS6xodklVjS7xECzSySaXSLQ7BJCs0t0NLsILmEXwUV2EVxkF8Gl5iS41JoElxqT4FJbElxqSoJLLUlwqSGBpWYEFaPAxCQQMQg86nOZS41nLvVE8Mp92Xbfvw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Moeda = _t, Date = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Moeda", type text}, {"Date", type date}, {"Value", Int64.Type}}), FilteredRows = Table.SelectRows(#"Changed Type", each [Date] >= Date.AddDays(DateTime.Date(DateTime.LocalNow()), -30) and [Date] <= DateTime.Date(DateTime.LocalNow())) in FilteredRows
Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.