Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowHi,
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.
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:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
24 | |
15 | |
12 | |
12 | |
8 |
User | Count |
---|---|
30 | |
24 | |
16 | |
15 | |
12 |