cancel
Showing results for
Did you mean:
Super User IV

## Re: Measure to calculate how many times the same item occured in past weeks

Hi @Cactus26,

Did you try my solution?  If you did and the result is not as expected then let me know of that exact case.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Regular Visitor

## Re: Measure to calculate how many times the same item occured in past weeks

The thing is that I do not store Occurence column in my project. As the occurence depends on filters chosen from slicers. Therefore I cannot create calculated column and I need a measure. Additionally I have thousands of items stored so it will be difficult to use your proposition. I tested @erik_tarnvik solution which is partially good but is missing the condition which check the items just for current week.

Highlighted

## Re: Measure to calculate how many times the same item occured in past weeks

Hi Cactus,

This code looks fine, somewhat tricky, but it does its job.

`Occ =VAR CurrentWeek = CALCULATE ( MAX ( Test[Week] ), ALLSELECTED ( Test[Item] ) )RETURN    COUNTROWS (        FILTER (            CALCULATETABLE ( VALUES ( Test[Item] ), Test[Week] = CurrentWeek ),            CALCULATE (                COUNTROWS ( Test ),                Test[Week] >= CurrentWeek - 2,                Test[Week] <= CurrentWeek - 1            )                >= 2        )    )`

Of course, you might need some minor modification and, most important, understand well how it works, since it hides some complexities in the definitino of CurrentWeek and the determination of the items.

Have fun with DAX!

Alberto Ferrari
http://www.sqlbi.com

Alberto Ferrari - SQLBI
Established Member

## Re: Measure to calculate how many times the same item occured in past weeks

Hi again @Cactus26,

glad we are close, did you test my second suggestion, or the one suggested by @AlbertoFerrari (more elegant as I would expect) from him)? My second suggestion does account for selecting a "current week". If this is not what you meant by that, please explain.

Regular Visitor

## Re: Measure to calculate how many times the same item occured in past weeks

Yes I tested your two solutions but it did not get fully expected results. However now I tested formula given by @AlbertoFerrari and it works perfectly!  Thank you all for the help 🙂

Established Member

## Re: Measure to calculate how many times the same item occured in past weeks

Excellent!

Announcements

#### 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.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### January 2020 Community Highlights

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

Top Solution Authors
Top Kudoed Authors