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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pawelj795
Post Prodigy
Post Prodigy

Count Items which occurs again

Hi,
I need to create 2 measures.

  • The first one should count how many items occur again today.
  • The second one should tell how many times this particular item occur in the past.

 

Sample data below:

DateItem ID
02.10.2020 (today)

A

02.10.2020B
02.10.2020C
01.10.2020B
28.09.2020C
27.09.2020C
1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hello @pawelj795 ,

Please try this:

Measure 1 = 
var t1_= 
    CALCULATETABLE (
        VALUES ( 'Table'[Item ID] ),
        FILTER (
            ALL ( 'Table'[Date] ),
            'Table'[Date] < MAX('Table'[Date]) )
        )
var t2_= 
    CALCULATETABLE (
        VALUES ( 'Table'[Item ID] ),
        FILTER (
            ALL ( 'Table'[Date] ),
            'Table'[Date] = MAX('Table'[Date]) )
        )
return
COUNTROWS(INTERSECT(t1_,t2_))
Measure 2 = CALCULATE(COUNT('Table'[Date]),ALLEXCEPT('Table','Table'[Item ID]))
Best Regards,
Xue Ding
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

4 REPLIES 4
v-xuding-msft
Community Support
Community Support

Hello @pawelj795 ,

Please try this:

Measure 1 = 
var t1_= 
    CALCULATETABLE (
        VALUES ( 'Table'[Item ID] ),
        FILTER (
            ALL ( 'Table'[Date] ),
            'Table'[Date] < MAX('Table'[Date]) )
        )
var t2_= 
    CALCULATETABLE (
        VALUES ( 'Table'[Item ID] ),
        FILTER (
            ALL ( 'Table'[Date] ),
            'Table'[Date] = MAX('Table'[Date]) )
        )
return
COUNTROWS(INTERSECT(t1_,t2_))
Measure 2 = CALCULATE(COUNT('Table'[Date]),ALLEXCEPT('Table','Table'[Item ID]))
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@pawelj795 ,

The information you have provided is not making the problem clear to me. Can you please explain with an example.

These can be two measures what I can get from a high level

 

calculate(distinctcount(Table[Item ID]), Table[Date] =today())

calculate(distinctcount(Table[Item ID]), Table[Date] < today())


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

Alluding to my above sample, I explain what I meant.

 

  • First measure:
    The result should be 2, because only item "B" and item "C" appear again today.
  • Second measure:
    For the Item "B" the result should be 2. (also include today) - It appeared on 02.10.2020 and 01.10.2020
    For the Item "C" the result should be 3. - It appeared on 02.10.2020, 28.09.2020, and 27.09.2020.

    If it's still not clear to you, please tell me which part is confusing.

.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (4,217)