Forum Discussion
Between 2 dates in FILTER function
Hi there,
I need to filter a table based on a selected MONTH and YEAR, the user can select multiple months also.
This is my measure:
Guys the problem was solved in another post i did.
Link to solution: https://community.powerbi.com/t5/Desktop/Measure-with-multiple-dates/m-p/892328#M427770Thank you so much for the help.
7 Replies
- amitchandakSuper User
If your date table is joined with your fact/data table. Why do need to filter. If you use month and year slicer from Date table it should work.
What is the logic you need? EOMONTH, and ENDOFMONTH can be used for the end date of the month. please find the example below to see how it is used
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date])) last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH))) last MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-1,MONTH)))) last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date Filer],-12,MONTH)))) MTD (Year End) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date Filer]))) MTD (Last Year End) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date Filer],-12,MONTH),"8/31")))- gazz9arFrequent Visitor
I have to Filter because as you can see, im using USERELATIONSHIP after.
First, i obtain every record based on month and year selected by the user.
Later i want visualize the SUM of those records based on other date column in the fact table.
- v-frfei-msftCommunity Support
Hi gazz9ar ,
Try this one please.
Total Checks (SINDESC) Filtered = VAR selectedyear = SELECTEDVALUE ( Dates[Año] ) VAR selectedmonth = ALLSELECTED ( Dates[MonthNum] ) RETURN CALCULATE ( [Total Checks (SINDESC)]; FILTER ( Cobros; Cobros[Fecha Contabilizacion] >= DATE ( selectedyear; selectedmonth; "01" ) && Cobros[Fecha Contabilizacion] <= DATE ( selectedyear; selectedmonth; "31" ) ); USERELATIONSHIP ( Dates[Date]; Cobros[Fecha Vencimiento Cheque] ) )If it doesn't meet your requirement, Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.
- gazz9arFrequent Visitor
Guys the problem was solved in another post i did.
Link to solution: https://community.powerbi.com/t5/Desktop/Measure-with-multiple-dates/m-p/892328#M427770Thank you so much for the help.