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
JAJ09
New Member

Need help to count periods with the same data

Hi there, I am trying to count periods in which a specific condition is active but the count restarts if the data changes in the time sequence

 

Example of data and expected data:

JAJ09_0-1681979249050.png

 

I am hoping to avoid the new OFFSET function as it seems it is not available in Analysis Services on Visual Studio which is what I need to deploy to.

 

 

 

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

hI @JAJ09 ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create a measure.

MEASURE = 
VAR _date =
    CALCULATE (
        MAX ( 'Table'[period] ),
        FILTER (
            ALL ('Table' ),
            'Table'[Type] <> "V"
                && 'Table'[period] <= SELECTEDVALUE('Table'[period]) 
                
    ))     
VAR _times =
    CALCULATE (
        COUNTROWS ('Table'),
        FILTER (
            ALL ( 'Table' ),
            'Table'[period] <= SELECTEDVALUE('Table'[period])
                &&'Table'[period] > _date
                
        )
    ) + 0 
RETURN
    _times

vrongtiepmsft_0-1682303476008.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

1 REPLY 1
v-rongtiep-msft
Community Support
Community Support

hI @JAJ09 ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create a measure.

MEASURE = 
VAR _date =
    CALCULATE (
        MAX ( 'Table'[period] ),
        FILTER (
            ALL ('Table' ),
            'Table'[Type] <> "V"
                && 'Table'[period] <= SELECTEDVALUE('Table'[period]) 
                
    ))     
VAR _times =
    CALCULATE (
        COUNTROWS ('Table'),
        FILTER (
            ALL ( 'Table' ),
            'Table'[period] <= SELECTEDVALUE('Table'[period])
                &&'Table'[period] > _date
                
        )
    ) + 0 
RETURN
    _times

vrongtiepmsft_0-1682303476008.png

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.