Forum Discussion
Build Table filtered by Date
hello,
I would like to filter a table, which has a date dimension, by a specific date.
I have created a new table with the following code:
test =
FILTER(
Maschinenstunden,
Maschinenstunden[Datum] = DATE(YEAR([gewaehltes Datum]),MONTH([gewaehltes Datum]),DAY([gewaehltes Datum]))
)
This does not change the original table in any way.
But if I use the following code it does what it should do:
test =
FILTER(
Maschinenstunden,
Maschinenstunden[Datum] = DATE(2021,3,10))
)
In this case, only the rows containing the specified date, are correctly in the table.
The Mesaure "gewaehltes Datum" is coded like this:
gewaehltes Datum = LASTDATE(Datumstabelle[Datum])
And the outcome is a single cell, which contains the correct date.
Why is this not transferable. So why does only the method with fixed numbers work?
Thank a lot for the help!
And sorry for the german named mesures and variables.
Greets
Hi Janush ,
You 'd better set table “gewaehltes Datum” as a variable.
Check the expression below:
test = var _tab=LASTDATE('Table'[Date]) Return FILTER( 'Table', 'Table'[Date]= DATE(YEAR(_tab),MONTH(_tab),DAY(_tab)) )And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
1 Reply
- v-kelly-msftCommunity Support
Hi Janush ,
You 'd better set table “gewaehltes Datum” as a variable.
Check the expression below:
test = var _tab=LASTDATE('Table'[Date]) Return FILTER( 'Table', 'Table'[Date]= DATE(YEAR(_tab),MONTH(_tab),DAY(_tab)) )And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!