Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sayang194
Frequent Visitor

Filter 12 months previous

Hi,

 

I want to count rows for the current month & for 12 months previous (I dont want any data in between). Only for current month & 12 months previous (Eg. May 2022 & May 2021)

 

I have the below formula that correctly filters for current month, but how can I modify this to filter the data that was 12 months back?

 

CALCULATE(
COUNT('table1'[ID]),
FILTER(DIM_Kalender, And(YEAR(DIM_Kalender[Date]) = YEAR(MAX('table1'[Date])), MONTH(DIM_Kalender[Date]) = MONTH(MAX('table1'[Date])))
)

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @sayang194 

 

Maybe you don't need to modify your DAX function. When you use Table1[Date] as a slicer, you can filter the data directly before December.

vzhangti_0-1653965208558.pngvzhangti_1-1653965224417.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @sayang194 

 

Maybe you don't need to modify your DAX function. When you use Table1[Date] as a slicer, you can filter the data directly before December.

vzhangti_0-1653965208558.pngvzhangti_1-1653965224417.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

JWilde
Regular Visitor

Hello,

I think you might be better off using TODAY() and EDATE(). Here's how I set a measure to look for data in a one-week window 12 months prior to a selected date:

JWilde_0-1653658861740.png

I think for what you're trying to do, you could just filter your table1 like so:

CALCULATE(
COUNTROWS('table1'),
FILTER('table1',
MONTH('table1'[Date]) = MONTH(EDATE(TODAY()),-12)
))

DataInsights
Super User
Super User

@sayang194,

 

Try this measure:

 

Last Year =
CALCULATE ( COUNT ( 'table1'[ID] ), SAMEPERIODLASTYEAR ( DIM_Kalender[Date] ) )




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.