Forum Discussion

Ricky97's avatar
Ricky97
Regular Visitor
1 year ago
Solved

Visualizing Case Trends with Subscription Start and End Dates for Accounts

I need to track the total number of cases raised by an account, where each account will raise multiple subscription requests, each with a start and end date. I'd like to create a plot that shows the ...
  • shafiz_p's avatar
    1 year ago

    Hi Ricky97 
    In power bi line chart you would not be able to create a x axis constant line for categorical or text label. If you have number in X axis, then you can create constant line to identify subscription start and end date. But in your case it is a categorical.

    You need to use custome visual which provide such functionality.

    However, you could get similar artifact using Line and Stacked column chart. See Some of the examples:

    Here is the data model:

     

    Created few extra column in Subscription table, See code below:

    MonthYearSubscriptionTable = FORMAT('Subscription'[START DATE], "MMM-YYYY")
    
    MonthYearEndDate = FORMAT('Subscription'[END DATE], "MMM-YYYY")

    Image:

     

     

    To create a column for Subscription Start Date, Use this measure:

    CheckMonthYearMatch = 
    IF(
        CALCULATE(
            COUNTROWS('Subscription'),
            'Subscription'[MonthYearSubscriptionTable] = SELECTEDVALUE('Calendar'[Month-Year])
        ) > 0,
        7,
        BLANK()
    )

     To create a column for Subscription End Date, Use this measure:

    CheckMonthYearMatchEnd = 
    IF(
        CALCULATE(
            COUNTROWS('Subscription'),
            'Subscription'[MonthYearEndDate] = SELECTEDVALUE('Calendar'[Month-Year])
        ) > 0,
        7, // You could use measure to get the max count within all month, to set the hight of the column
        BLANK()
    )

     

    For custom data label for columns, Create below measure for Subscription Start Date:

    CheckMonthYearMatchStartDate = 
    IF(
        CALCULATE(
            COUNTROWS('Subscription'),
            'Subscription'[MonthYearSubscriptionTable] = SELECTEDVALUE('Calendar'[Month-Year])
        ) > 0,
        "Start Date : " & FORMAT(MINX(
            FILTER(
                'Subscription',
                'Subscription'[MonthYearSubscriptionTable] = SELECTEDVALUE('Calendar'[Month-Year])
            ),
            'Subscription'[START DATE]
        ), "MM-DD-YY") & " " &
        MINX(
            FILTER(
                'Subscription',
                'Subscription'[MonthYearSubscriptionTable] = SELECTEDVALUE('Calendar'[Month-Year])
            ),
            'Subscription'[CR Name]
        ),
        BLANK()
    )

     

    For Subscription End Date:

    CheckMonthYearMatchEndDate = 
    IF(
        CALCULATE(
            COUNTROWS('Subscription'),
            'Subscription'[MonthYearEndDate] = SELECTEDVALUE('Calendar'[Month-Year])
        ) > 0,
        "End Date : " & FORMAT(MINX(
            FILTER(
                'Subscription',
                'Subscription'[MonthYearEndDate] = SELECTEDVALUE('Calendar'[Month-Year])
            ),
            'Subscription'[END DATE]
        ), "MM-DD-YY") & " " & 
        MINX(
            FILTER(
                'Subscription',
                'Subscription'[MonthYearEndDate] = SELECTEDVALUE('Calendar'[Month-Year])
            ),
            'Subscription'[CR Name]
        ),
        BLANK()
    )

     

     

    Place measure to create Visual column in the visual Column-Y Axis, and CountCase measure in the Line Y-Axis:

    Update data labels with the corresponding measure, see image :

     

    PBIX : 

     

     

    Hope this helps!!

    If this solved your problem, please accept it as a solution and a kudos!!

    Best Regards,
    Shahariar Hafiz