Search code examples
powerbidaxvisualizationpowerbi-desktopdata-modeling

Power BI :: line chart based on two different date range


Not sure if this is possible.

I have a dashboards that compares 2 different date ranges.

I have created a Line Chart based on the first calendar and first costs of the month:

enter image description here

Now I would like to add a second line but that line is based on a different calendar.

And there is no second X-axis to add.

Is this possible?

I tried this solution but it cannot apply to me.

Files are here:


Solution

  • UPDATE2

    In settings, uncheck the following.

    enter image description here

    Create the calendar table as follows to add all your columns you will need (you can add more later).

    Calendar = 
    
    ADDCOLUMNS (
            CALENDARAUTO( ),
        "Calendar Year", "CY " & YEAR ( [Date] ),
        "Month Name", FORMAT ( [Date], "mmmm" ),
        "Month Number", MONTH ( [Date] ),
        "Weekday", FORMAT ( [Date], "dddd" ),
        "Weekday number", WEEKDAY( [Date] ),
        "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1)
    

    Create a relationship between new calendar table and data table.

    enter image description here

    Change your measures as follows:

    From

    MoM Month to Date = 
    CALCULATE(
        SUM(Data[Cost]),
        DATESMTD(Data[UsageDate].[Date]))
    

    To

    MoM Month to Date = 
    CALCULATE(
        SUM(Data[Cost]),
        DATESMTD('Calendar'[Date]))
    

    UPDATE

    How about this?

    enter image description here

    If so, just make the field well of the visual contain day only like this:

    enter image description here

    Do you mean like this?

    enter image description here

    If so, create a new calendar table

    Calendar = CALENDARAUTO()
    

    Join to your Data table as a 1 to many.

    enter image description here

    Use the date field from the new calendar table in the x axis.

    enter image description here