cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Comparison of Count of rows filtered by a condition , while also using DATEADD

Hi All,

PFB a measure.

Measure = CALCULATE (

COUNTROWS(FILTER('TableName', 'TableName'[Column Name x ] = "Yes")),
DATEADD ( 'TableName'[Year], -12, MONTH ))
 
What I am trying to achieve is that:

I need to count the number of rows where a particular column has value as "Yes" for Date as 1 year Back .
 
 
I am not able to use CALCULATE as it cannot operate for Boolean values in this case , Column Name x has 2 values and I need to count only for values as "Yes".
 
Thanks for Help in advance.
 
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

Not Excatly according to the need. 
Only returning value for current year i.e 2019 , returns a numeric value.

 

I tried using SAMEPERIODLASTYEAR and that seems to work fine.

Thanks ,

View solution in original post

6 REPLIES 6
mnayar Established Member
Established Member

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

@Anonymous Try creating a measure like this:

 

CALCULATE(DISTINCTCOUNT(<UNIQUE ROW IDENTIFIER>), FILTER('TableName', 'TableName'[Column Name x ] = "Yes")), FILTER(TableName, TableName[Date]>=DATEADD(TableName[Date],-1,year)))

Community Support Team
Community Support Team

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

@Anonymous ,

 

The date value in Year column is month, not year, right? To be general, you may also try measure below:

Measure =
CALCULATE (
    COUNTROWS ( 'TableName' ),
    FILTER ( 'TableName', 'TableName'[Column Name x ] = "Yes" ),
    DATEADD ( 'TableName'[Year], -12, MONTH )
)

Community Support Team _ Jimmy Tao

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

Anonymous
Not applicable

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

Hi,

Thanks for the suggestion , but the measure returns Blank if I select any date in slicer which does not lie in 2019.

It returns data for only values of 2019, wheres I have data for last 10 years

mnayar Established Member
Established Member

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

@Anonymousjust to make sure my formula also didnt work?

Anonymous
Not applicable

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

Not Excatly according to the need. 
Only returning value for current year i.e 2019 , returns a numeric value.

 

I tried using SAMEPERIODLASTYEAR and that seems to work fine.

Thanks ,

View solution in original post

Community Support Team
Community Support Team

Re: Comparison of Count of rows filtered by a condition , while also using DATEADD

@Anonymous ,

 

Have you solved your issue by now? If you have, could you please help mark the correct answer to finish the thread? Your contribution will be much appreciated.

 

Regards,

Jimmy Tao

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors