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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ghouse_peer
Post Patron
Post Patron

Last 6 months average

Hello Guys,

 

I need to show last 6 months average Opened and closed tickets in 2 seperate card visuals. 1 card for Opened tickets and 1 card for closed tickets.

 

Data: Table name: Tickets; Columns: Ticket Number, Opened Date, Closed date

          Table Name: Dates; (Created using calendar)

 

kindly help me with calculation or solution. 

 

 

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion


Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
AntrikshSharma
Super User
Super User

Try something like this assuming you already have a realtionship between opened date and dates for the below measure.

 

Opened Tickets =
VAR TimeSpan = 6
VAR MaxVisibleMonth =
    MAX ( Dates[Month Number] )
VAR ListOfDates =
    FILTER (
        ALL ( Dates ),
        Dates[Date] <= MAX ( Dates[Date] )
            && Dates[Month Number] <= MaxVisibleMonth
            && Dates[Month Number] > MaxVisibleMonth - TimeSpan
    )
VAR Result =
    CALCULATE ( [Average Sales], ListOfDates )
RETURN
    Result

For closed one use this.

Closed tickets =
VAR TimeSpan = 6
VAR MaxVisibleMonth =
    MAX ( Dates[Month Number] )
VAR ListOfDates =
    FILTER (
        ALL ( Dates ),
        Dates[Date] <= MAX ( Dates[Date] )
            && Dates[Month Number] <= MaxVisibleMonth
            && Dates[Month Number] > MaxVisibleMonth - TimeSpan
    )
VAR Result =
    CALCULATE (
        [Average Sales],
        ListOfDates,
        USERELATIONSHIP ( Sales[OpenedTicket], Dates[Date] )
    )
RETURN
    Result

 

@AntrikshSharma  I have already created relationships between Dates Table and Opened,closed dates in tickets table. Opened date is active and closed date is inactive. I Tried the dax of urs too donno wr m gng wrong. Kindly use the cloumn names from below data and provide me the dax. So tht it will be helpfull. Kindly help.

 

Tickets

Table Name: Tickets  
Opened DateClosed Date Ticket Number
1/29/20207/1/20201122
1/2/20206/10/20202233
2/15/20206/10/20201313
1/12/20206/15/20201212
2/15/20206/15/20201111
2/29/20206/2/20203131
2/1/20206/2/20203434
1/1/20206/6/20203535
2/2/20206/6/20203232
2/3/20206/6/20203233

 

Dates

Table Name: Dates
Dates
1/29/2020
1/2/2020
2/15/2020
1/12/2020
2/15/2020
2/29/2020
2/1/2020
1/1/2020
2/2/2020
2/3/2020

 

Thanks in advance

Anonymous
Not applicable

Hi @ghouse_peer,

You can take a look at the following link to expand these date field to create a bridge table to link original table, then you can simply analyst records between two date range:

Spread revenue across period based on start and end date, slice and dase this using different dates 

Regards,

Xiaoxin Sheng

amitchandak
Super User
Super User

@ghouse_peer , You need to join date table with both dates. and then use userelation to choose the dates in formulas given below

For userelation : https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Example of 6 month Avg. Add use relation before calculate ends.

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-6,MONTH)) /6
Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX(Sales[Sales Date]),-6,MONTH))  /6

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  I have already created relationships between 'Dates' table and Opened and closed dates. Opened date is active and closed date is inactive. I tried using the dax provided by you. But i am missing somwhere in that. Can u please use this data and provide me the same dax for both opened and closed tickets  using userelationship. Kindly help me for the solution.

Tickets

Table Name: Tickets  
 Opened Date Closed Date Ticket Number
1/29/20207/1/20201122
1/2/20206/10/20202233
2/15/20206/10/20201313
1/12/20206/15/20201212
2/15/20206/15/20201111
2/29/20206/2/20203131
2/1/20206/2/20203434
1/1/20206/6/20203535
2/2/20206/6/20203232
2/3/20206/6/20203233

 

Dates

Table Name: Dates
Dates
1/29/2020
1/2/2020
2/15/2020
1/12/2020
2/15/2020
2/29/2020
2/1/2020
1/1/2020
2/2/2020
2/3/2020

 

thanks in advance.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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