Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Help with generating a summary table

Hello,

I want to create a summary table in Power BI that tells me the amount of tickets for a week for example:

Fromto
2024-20-052024-26-05
Tickets inTickets out
810

From the following example dataset:

TicketDate inDate out
A-112-04-202420-05-2024
A-219-04-202420-05-2024
A-321-05-202420-05-2024
A-421-05-202421-05-2024
A-521-05-202422-05-2024
A-621-05-202423-05-2024
A-725-05-202424-05-2024
A-825-05-202425-05-2024
A-925-05-202425-05-2024
A-1025-05-202425-05-2024

The problem I have is that I can't find a way to assign the number of tickets in the same table or chart using different dates (see example) because tickets that are closed during the week were not necessarily created that same week.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi,Anonymous. Hello,ryan_mayu ,thanks for your concern about this issue.And I would like to share some additional solutions below.
    I am glad to help you.

    According to your description, you want to count the number of tickets in a selected time period

    You could refer to my test result below, hope it can help you.
    Here is my test data:

    I created two measures to calculate the number of Tickets whose DateIn and DateOut are within the range selected by the slicer.

    Here is the Dax code

    M_ticketIn = 
    VAR minDate=MIN('Dates'[Date])
    VAR maxDate=MAX('Dates'[Date])
    RETURN
    CALCULATE(
        COUNT(SaleTicket[Ticket]),FILTER(ALL(SaleTicket),'SaleTicket'[Date in]>=minDate&&'SaleTicket'[Date in]<=maxDate))
    
    M_ticketOut = 
    VAR minDate=MIN('Dates'[Date])
    VAR maxDate=MAX('Dates'[Date])
    RETURN
    CALCULATE(
        COUNT('SaleTicket'[Ticket]),FILTER(ALL('SaleTicket'),'SaleTicket'[Date out]>=minDate&&'SaleTicket'[Date out]<=maxDate))
    

    I've created a measrue M_result that counts the number of Tickets that match both DateIn and DateOut for the selected time period.

    i.e. the number of tickects that start and end in the selected time period.

    M_result = 
    IF('SaleTicket'[M_ticketIn]<='SaleTicket'[M_ticketOut],'SaleTicket'[M_ticketIn],'SaleTicket'[M_ticketOut])
    

    You can also try to use the WeekNum function to get the number of weeks for each date to calculate (this avoids having to set the time period manually).
    Here is the test result:

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian,

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi,

    I cannot understand your expected result of 8 and 10?  Explain that in detail.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,Anonymous. Hello,ryan_mayu ,thanks for your concern about this issue.And I would like to share some additional solutions below.
    I am glad to help you.

    According to your description, you want to count the number of tickets in a selected time period

    You could refer to my test result below, hope it can help you.
    Here is my test data:

    I created two measures to calculate the number of Tickets whose DateIn and DateOut are within the range selected by the slicer.

    Here is the Dax code

    M_ticketIn = 
    VAR minDate=MIN('Dates'[Date])
    VAR maxDate=MAX('Dates'[Date])
    RETURN
    CALCULATE(
        COUNT(SaleTicket[Ticket]),FILTER(ALL(SaleTicket),'SaleTicket'[Date in]>=minDate&&'SaleTicket'[Date in]<=maxDate))
    
    M_ticketOut = 
    VAR minDate=MIN('Dates'[Date])
    VAR maxDate=MAX('Dates'[Date])
    RETURN
    CALCULATE(
        COUNT('SaleTicket'[Ticket]),FILTER(ALL('SaleTicket'),'SaleTicket'[Date out]>=minDate&&'SaleTicket'[Date out]<=maxDate))
    

    I've created a measrue M_result that counts the number of Tickets that match both DateIn and DateOut for the selected time period.

    i.e. the number of tickects that start and end in the selected time period.

    M_result = 
    IF('SaleTicket'[M_ticketIn]<='SaleTicket'[M_ticketOut],'SaleTicket'[M_ticketIn],'SaleTicket'[M_ticketOut])
    

    You can also try to use the WeekNum function to get the number of weeks for each date to calculate (this avoids having to set the time period manually).
    Here is the test result:

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.

    Best Regards,

    Carson Jian,

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hi,

    I cannot understand your expected result of 8 and 10?  Explain that in detail.