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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Received vs Closed against Year/Month

How to get the count of received and closed tickets per month/year based on the sample data below?

 

TicketReceived dateClosed date
Ticket101-Jan-201702-Jan-2017
Ticket203-Jan-201701-Feb-2017
Ticket305-Jan-2017 
Ticket401-Feb-201704-Feb-2017
Ticket029-Dec-201711-Jan-2017

 

Expected result:

 

YearMonthReceivedClosed
2016December10
2017January32
2017February12

 

 

Appreciate the help!

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

According to your description above, you should be able to follow steps below to get your expected result.

 

1. Create an individual Calendar table if you don't have it yet.

Date = CALENDAR("2016/01/01","2017/12/31")

2. Use formula below to  create "Year" column, and "Month" column in the Calendar table.

Year = YEAR('Date'[Date])

Month = FORMAT('Date'[Date],"mmmm")

3. Create two relationships between your table and the Calendar table with "Received date" and "Date"(active), "Closed date" and "Date" (inactive).

 

r1.PNG

 

4. Use formula below to create different measures to calculate "Received" and "Closed".

Received = COUNTA(Table1[Received date])

Closed = CALCULATE(COUNTA(Table1[Closed date]), USERELATIONSHIP(Table1[Closed date],'Date'[Date]))

5. Show "Received" and "Closed" with "Year" and "Month" column in a Table visual.

 

result1.PNG

 

Here is the sample pbix file for your reference.Smiley Happy

 

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

According to your description above, you should be able to follow steps below to get your expected result.

 

1. Create an individual Calendar table if you don't have it yet.

Date = CALENDAR("2016/01/01","2017/12/31")

2. Use formula below to  create "Year" column, and "Month" column in the Calendar table.

Year = YEAR('Date'[Date])

Month = FORMAT('Date'[Date],"mmmm")

3. Create two relationships between your table and the Calendar table with "Received date" and "Date"(active), "Closed date" and "Date" (inactive).

 

r1.PNG

 

4. Use formula below to create different measures to calculate "Received" and "Closed".

Received = COUNTA(Table1[Received date])

Closed = CALCULATE(COUNTA(Table1[Closed date]), USERELATIONSHIP(Table1[Closed date],'Date'[Date]))

5. Show "Received" and "Closed" with "Year" and "Month" column in a Table visual.

 

result1.PNG

 

Here is the sample pbix file for your reference.Smiley Happy

 

Regards

Anonymous
Not applicable

@v-ljerr-msft and @tringuyenminh92 thanks for the help!

tringuyenminh92
Memorable Member
Memorable Member

Hi @Anonymous,

 

Cause your data structure has 2 date columns so i will unpivot these column by Query Editor:

Edit Queries -> Transform tab -> Unpivot columns -> rename result to Action and Date columns

 

Screenshot 2017-02-07 14.02.44.pngScreenshot 2017-02-07 14.03.03.png

 

Create calculated column for showing Month-Year from Date column:

Month_Year = Data[Date].[Month] & "-" & Data[Date].[Year]

(if Date column does not support .[Month] and .[Year], you could use Month() and Year() function to extract these values)

 

Create calculated column for order column

MonthYearNo = Data[Date].[MonthNo] + Data[Date].[Year]*100

Choose Month_Year column and sort by column MonthYearNo

 

 

In case you want to show Received and Closed values without "date" in the end, you could add one more transform step: (right click Action column -> choose Replace value -> input "date" and empty

Screenshot 2017-02-07 14.11.32.pngScreenshot 2017-02-07 14.11.18.png

 

Result with matrix control:

Screenshot 2017-02-07 14.14.57.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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