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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

How to find repeated values over consecutive weeks?

Hi!

 

I have different categories, labeled as 'PICKER BEHAVIOUR CLASS', these categories have a group of IDs, and there's a quantity of IDs that match these categories every week. For Example, the IDs 1, 2 and 3 in February 7th fell into this category,  then the next week, February 14th, the IDs 1 and 2 fell into this category again. What I want to know is if there's a way I can count how many IDs repeated category. In this case, for the week of February 14th, the result should be 2. 

 

I expect something like these to be the result. 

luis_murilo_0-1652365291842.png

Can anybody please help me?

 

Best Regards

1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer the formula.

count_ =
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[category] = SELECTEDVALUE ( 'Table'[category] )
                && 'Table'[week]
                    = SELECTEDVALUE ( 'Table'[week] ) - 1
        )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[id] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[week], 'Table'[category] ),
            'Table'[id] IN tmp
        )
    )

vjaywmsft_1-1652775015935.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please refer the formula.

count_ =
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[id] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[category] = SELECTEDVALUE ( 'Table'[category] )
                && 'Table'[week]
                    = SELECTEDVALUE ( 'Table'[week] ) - 1
        )
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[id] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[week], 'Table'[category] ),
            'Table'[id] IN tmp
        )
    )

vjaywmsft_1-1652775015935.png

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. Avoid posting screenshots of your source data if possible.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.