The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, I have a table that's based on the DAX below. It's a count of every possible combination based on a project and system when an IT ticket is made.
I need to add a date slicer to the page so that the figures in a matrix table changes with the date. I feel like I either need to add the Created_Date to the existing DAX, or add the Ticket_ID and make a relationship to the source data. How can I add the date or ticket ID to the DAX below, please?
Solved! Go to Solution.
To make your matrix respond to a date slicer, you need a measure that calculates the ticket count based on the filters currently applied to your report, including the date range.
Instead of trying to embed the date into your Ticket_Every_Combination table, use it to define the rows and columns of your matrix. If Tickets[System] and Tickets[Project] already give you all the combinations you need, you might not even need the Ticket_Every_Combination table itself in your visual. You can just drag those columns directly into your matrix.
However, if you want a complete list of every possible combination even if no tickets exist for them, your current Ticket_Every_Combination calculated table is useful:
Ticket_Every_Combination = VAR Systems = VALUES(Tickets[System]) VAR Project = VALUES(Tickets[Project]) RETURN CROSSJOIN(Systems, Project)
This table simply lists all unique System-Project pairs. You'd use columns from this table in your matrix rows/columns.
For proper date filtering, especially if you plan on more complex time intelligence later, always use a Date table.
Create a Date Table: If you don't have one, create a calculated table for dates.
DateTable = CALENDARAUTO() // This automatically generates dates from your data model
Go to the Model view, select your DateTable, and in the Properties pane, mark it as a Date table.
Create a Relationship: In the Model view, drag the Date column from DateTable to the Created_Date column in your Tickets table. This creates a one-to-many relationship (one date in DateTable can have many tickets). Ensure this relationship is active.
This is the core of the solution. This measure will count tickets based on the Project, System, and any applied date filters.
Count of Tickets by Combination = COUNTROWS( FILTER( ALLSELECTED(Tickets), Tickets[System] = MAX(Tickets[System]) && Tickets[Project] = MAX(Tickets[Project]) ) )
How this measure works:
Hi @RichOB
1. Create a date table if you don't have one
Calendar = CALENDAR( MIN(Tickets[Created_Date]), MAX(Tickets[Created_Date]) )
Ticket_Combinations_Filterable = VAR Systems = VALUES(Tickets[System]) VAR Projects = VALUES(Tickets[Project]) RETURN ADDCOLUMNS( CROSSJOIN(Systems, Projects), "Count", VAR CurrentSystem = [System] VAR CurrentProject = [Project] RETURN CALCULATE( COUNTROWS(Tickets), USERELATIONSHIP('Calendar'[Date], Tickets[Created_Date]), Tickets[System] = CurrentSystem, Tickets[Project] = CurrentProject ) )
Add a date slicer using your Calendar table
Create a matrix visual with:
Rows: [System] and [Project] from your combination table
Values: [Count]
The count will automatically filter based on the date selection
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
Hi @RichOB,
To make your measure responsive to a date slicer, you need to ensure that the count logic respects the filter context from the Created_Date column. Right now, you're generating all combinations of System and Project using CROSSJOIN, which creates a disconnected virtual table, so the date filter is ignored. The fix is to calculate the count using CALCULATE, which preserves slicer context, including any applied date filters.
Here's how you can revise your DAX:
Ticket_Every_Combination :=
VAR Systems = VALUES(Tickets[System])
VAR Projects = VALUES(Tickets[Project])
RETURN
ADDCOLUMNS(
CROSSJOIN(Systems, Projects),
"Count",
CALCULATE(
COUNTROWS(Tickets),
FILTER(
Tickets,
Tickets[System] = EARLIER(Tickets[System]) &&
Tickets[Project] = EARLIER(Tickets[Project])
)
)
)
This version keeps your original logic but wraps the COUNTROWS in a CALCULATE, which allows the filter from a slicer on Tickets[Created_Date] to flow through properly. As long as the Created_Date field is in the Tickets table or related to it, your matrix will now update correctly based on the selected date range.
Best regards,
Hi @RichOB ,
Could you please confirm if the issue has been resolved on your end? If a solution has been found, it would be greatly appreciated if you could share your insights with the community. This would be helpful for other members who may encounter similar issues.If our answer resolved your query,consider accepting it as solution.
Thank you for your understanding and assistance.
Hi @RichOB ,
Just checking in — did the solution provided help resolve your issue? If yes, please consider marking it as the accepted answer so it can help others facing a similar challenge.If still needed further assistance, feel free to reachout!
Thank you.
Hi @RichOB ,
Thank you @DataNinja777 and @Elena_Kalina , @freginier for the prompt responses!
May I check if your issue has been resolved? If it has, please consider marking the helpful reply or sharing your solution and accepting it. This helps other community members with similar questions find answers more quickly.
Thank you for being a part of Microsfot Fabric Community Forum!
Regards,
Pallavi G.
Hi @RichOB,
To make your measure responsive to a date slicer, you need to ensure that the count logic respects the filter context from the Created_Date column. Right now, you're generating all combinations of System and Project using CROSSJOIN, which creates a disconnected virtual table, so the date filter is ignored. The fix is to calculate the count using CALCULATE, which preserves slicer context, including any applied date filters.
Here's how you can revise your DAX:
Ticket_Every_Combination :=
VAR Systems = VALUES(Tickets[System])
VAR Projects = VALUES(Tickets[Project])
RETURN
ADDCOLUMNS(
CROSSJOIN(Systems, Projects),
"Count",
CALCULATE(
COUNTROWS(Tickets),
FILTER(
Tickets,
Tickets[System] = EARLIER(Tickets[System]) &&
Tickets[Project] = EARLIER(Tickets[Project])
)
)
)
This version keeps your original logic but wraps the COUNTROWS in a CALCULATE, which allows the filter from a slicer on Tickets[Created_Date] to flow through properly. As long as the Created_Date field is in the Tickets table or related to it, your matrix will now update correctly based on the selected date range.
Best regards,
Hi @RichOB
1. Create a date table if you don't have one
Calendar = CALENDAR( MIN(Tickets[Created_Date]), MAX(Tickets[Created_Date]) )
Ticket_Combinations_Filterable = VAR Systems = VALUES(Tickets[System]) VAR Projects = VALUES(Tickets[Project]) RETURN ADDCOLUMNS( CROSSJOIN(Systems, Projects), "Count", VAR CurrentSystem = [System] VAR CurrentProject = [Project] RETURN CALCULATE( COUNTROWS(Tickets), USERELATIONSHIP('Calendar'[Date], Tickets[Created_Date]), Tickets[System] = CurrentSystem, Tickets[Project] = CurrentProject ) )
Add a date slicer using your Calendar table
Create a matrix visual with:
Rows: [System] and [Project] from your combination table
Values: [Count]
The count will automatically filter based on the date selection
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
To make your matrix respond to a date slicer, you need a measure that calculates the ticket count based on the filters currently applied to your report, including the date range.
Instead of trying to embed the date into your Ticket_Every_Combination table, use it to define the rows and columns of your matrix. If Tickets[System] and Tickets[Project] already give you all the combinations you need, you might not even need the Ticket_Every_Combination table itself in your visual. You can just drag those columns directly into your matrix.
However, if you want a complete list of every possible combination even if no tickets exist for them, your current Ticket_Every_Combination calculated table is useful:
Ticket_Every_Combination = VAR Systems = VALUES(Tickets[System]) VAR Project = VALUES(Tickets[Project]) RETURN CROSSJOIN(Systems, Project)
This table simply lists all unique System-Project pairs. You'd use columns from this table in your matrix rows/columns.
For proper date filtering, especially if you plan on more complex time intelligence later, always use a Date table.
Create a Date Table: If you don't have one, create a calculated table for dates.
DateTable = CALENDARAUTO() // This automatically generates dates from your data model
Go to the Model view, select your DateTable, and in the Properties pane, mark it as a Date table.
Create a Relationship: In the Model view, drag the Date column from DateTable to the Created_Date column in your Tickets table. This creates a one-to-many relationship (one date in DateTable can have many tickets). Ensure this relationship is active.
This is the core of the solution. This measure will count tickets based on the Project, System, and any applied date filters.
Count of Tickets by Combination = COUNTROWS( FILTER( ALLSELECTED(Tickets), Tickets[System] = MAX(Tickets[System]) && Tickets[Project] = MAX(Tickets[Project]) ) )
How this measure works: