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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jarenasv
Frequent Visitor

Count first occurrence by selected filters date

Hi, I am working with data visualization and trying not to count duplicates and not seeing how to accomplish, the objective is to count only the first ocurrence, using as a filter periods of dates, years, months etc and/or filtering the other related tables.

 

The objective is to work only with data that is displayed dynamically according to the selected filters.

 

Below is some made up data that should help explain issue:

2019-04-04_11-12-57.png

 

Another user from the community helped me with the issue of duplicity (v-lili6-msft ), but not work if I apply a filter to Date column or other filter of the related tables.

 

Measure used to count the first occurrence.

result = CALCULATE(COUNTROWS(Query),FILTER(Query,Query[DATE]=CALCULATE(MIN(Query[DATE]),ALLEXCEPT(Query,Query[ID]))))+0

In this measure, I would like to include the respective filters mentioned above. I have used the allselected function but it does not work.

 

Actually:

cambiar tabla.png

Issue when using the date filter:

Tabla 2.png

Expected result using filters:

Tabla 3.png

I emphasize that I can not occupy calculated columns is too much information and applying only the filters could reduce the processing times in Analysis Services 2014.

 

Thank You.

 

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

@jarenasv ,

 

You may try the following measure.

Measure =
SUMX (
    VALUES ( Query[ID] ),
    CALCULATE (
        VAR d =
            MIN ( Query[DATE] )
        RETURN
            IF ( d = CALCULATE ( MIN ( Query[DATE] ), ALLSELECTED ( Query[DATE] ) ), 1, 0 )
    )
)
Community Support Team _ Sam Zha
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-chuncz-msft
Community Support
Community Support

@jarenasv ,

 

You may try the following measure.

Measure =
SUMX (
    VALUES ( Query[ID] ),
    CALCULATE (
        VAR d =
            MIN ( Query[DATE] )
        RETURN
            IF ( d = CALCULATE ( MIN ( Query[DATE] ), ALLSELECTED ( Query[DATE] ) ), 1, 0 )
    )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors