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

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

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
v-yajiewan-msft
Community Support
Community Support

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.