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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RShackelford
Frequent Visitor

Tickets Opened and Closed per Month With Graph

What I need to do: 

Create a bar chart that shows the number of tickets opened and closed each month. 

 

This is a fairly simple task but I'm at sock puppet level with DAX and I'm really overthinking this. I assume I need to create a date table and link the open and closed fields? 

 

So from the data table I should be able get:

 Tickets OpenedTickets Closed
November74
December34

 

 
 

Capture.PNG

 

Sample Data:

Ticket NumOpenedClosedState
10620611/1/202011/28/2020Closed
10908111/15/202011/28/2020Closed
10886612/1/2020 Open
10046911/1/202012/15/2020Closed
10355611/15/202011/28/2020Closed
10824312/1/202012/15/2020Closed
10587612/1/2020 Open
10231711/1/202012/15/2020Closed
10402911/15/202011/28/2020Closed
10045011/1/202012/15/2020Closed

 

 

Thanks

2 ACCEPTED SOLUTIONS
MattAllington
Community Champion
Community Champion

Yes, get a calendar table with a month column, year column and date column (minimum). Create and active relationship to the opened column and an inactive relationship to the closed column. 
Write measures

Total opened = countrows(Data)

total closed = calculate([total opened],userelationship(calendar[date],data[closed date]))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

littlemojopuppy
Community Champion
Community Champion

Hi @RShackelford 

You want to create a date table and mark it accordingly.  Then you will create two relationships between the date table and your tickets data.  One between DateTable[Date] and Tickets[Opened] and the second between DateTable[Date] and Tickets[Closed].  Your data model should look something like this.

Screenshot 2020-12-29 162049.png

 

Then you need two measures

Tickets Opened:=CALCULATE(
		DISTINCTCOUNT(Tickets[Ticket Num]),
		USERELATIONSHIP('Calendar'[Date], Tickets[Opened])
	)

Tickets Closed:=CALCULATE(
		DISTINCTCOUNT(Tickets[Ticket Num]),
		USERELATIONSHIP('Calendar'[Date], Tickets[Closed])
	)

 

The output looks like this

Screenshot 2020-12-29 162230.png

View solution in original post

3 REPLIES 3
littlemojopuppy
Community Champion
Community Champion

Hi @RShackelford 

You want to create a date table and mark it accordingly.  Then you will create two relationships between the date table and your tickets data.  One between DateTable[Date] and Tickets[Opened] and the second between DateTable[Date] and Tickets[Closed].  Your data model should look something like this.

Screenshot 2020-12-29 162049.png

 

Then you need two measures

Tickets Opened:=CALCULATE(
		DISTINCTCOUNT(Tickets[Ticket Num]),
		USERELATIONSHIP('Calendar'[Date], Tickets[Opened])
	)

Tickets Closed:=CALCULATE(
		DISTINCTCOUNT(Tickets[Ticket Num]),
		USERELATIONSHIP('Calendar'[Date], Tickets[Closed])
	)

 

The output looks like this

Screenshot 2020-12-29 162230.png

MattAllington
Community Champion
Community Champion

Yes, get a calendar table with a month column, year column and date column (minimum). Create and active relationship to the opened column and an inactive relationship to the closed column. 
Write measures

Total opened = countrows(Data)

total closed = calculate([total opened],userelationship(calendar[date],data[closed date]))



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Thanks @MattAllington. That works. 

 

BTW, I just ordered your book before I posted this question. Small PBI world. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.