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

Count first Occurrence of Ticket by Month

Hi, 

 

Wondering if you can help. 

We have a model that is used by multiple users so would like to create this as a measure (no calc columns or power Query changes). 

 

Scenario: We have tickets that can be created against our products.

The user would like a YTD chart by month for the current year. 

The user would like to count the first occurrence of a specific ticket type (type ID 1) being raised against an product. 

Multiple occurrences of the same ticket type can be raised against one product. 

If the first occurence was outside of current YTD, then no tickets should be counted. 

Current YTD assumed to be 2024 Jan - Aug.

 

I thought I could get there using ADDCOLUMNS and adding a ranking column. 
I added the rank column but unsure how to use that added column to then restrict the results. 

 

Image showing data structure below. 

 

image.png

 

 

 

3 REPLIES 3
Anonymous
Not applicable

Hi @Louis020790 , ahadkarimi, thank you for your prompt reply!

 

Please create two measures as shown below:

 

FirstTicketMonth = CALCULATE(MIN('Table'[Year Month]),FILTER(ALL('Table'),'Table'[Product ID]=MAX('Table'[Product ID])&&'Table'[Ticket Type ID]=1))
IsCount = IF(MONTH([FirstTicketMonth])<=8 && YEAR([FirstTicketMonth])=2024&& MAX('Table'[Ticket Type ID])=1&& [FirstTicketMonth]=MAX('Table'[Year Month]),"Yes","No")

 

Result for your reference:

 

vyajiewanmsft_0-1725340066140.png

Best regards,

Joyce

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

ahadkarimi
Solution Specialist
Solution Specialist

Hi @Louis020790, try this measure below, and if you encounter any issues, let me know.

FirstOccurrenceCountYTD = 
VAR CurrentYear = 2024
VAR YTDEndMonth = 8
VAR FilteredTable = 
    FILTER(
        'TableName', 
        'TableName'[Ticket Type ID] = 1 &&
        YEAR('TableName'[Year Month]) = CurrentYear &&
        MONTH('TableName'[Year Month]) <= YTDEndMonth
    )
VAR MinYearMonthTable = 
    ADDCOLUMNS(
        SUMMARIZE(
            FilteredTable, 
            'TableName'[Product ID]
        ),
        "MinYearMonth", MINX(
            CALCULATETABLE(
                FilteredTable, 
                ALLEXCEPT('TableName', 'TableName'[Product ID])
            ),
            'TableName'[Year Month]
        )
    )
RETURN
    COUNTROWS(
        FILTER(
            MinYearMonthTable,
            'TableName'[MinYearMonth] <= (CurrentYear * 100 + YTDEndMonth)
        )
    )

Did I answer your question? If so, please mark my post as the solution! ✔️
Your Kudos are much appreciated! Proud to be a Solution Supplier!

Hi, 

 

Thanks for the proposal, but this doesn't work. 
No results returned in my test dataset. 

 

I alos removed Ticket Type to simplify further and counted all records of table

 

Louis020790_0-1727865301742.png

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.