powerbidaxpowerbi-desktop

Compare 6 month vs 6 month on a chart bar


I want to compare:

These are the measures:

In Season = 
CALCULATE(
    SUM('Compare'[Seasonality]),
    FILTER(
        'Compare',
        'Compare'[date] >= DATE(2024,10,1) &&
        'Compare'[date]  <= DATE(2025,3,31)
    )
)

And

Out of season = 
CALCULATE(
    SUM('Compare'[Seasonality]),
    FILTER(
        'Compare',
        'Compare'[date]  >= DATE(2024,4,1) &&
        'Compare'[date]  <= DATE(2024,9,30)
    )
)

PROBLEMS:

I was able to divide the two calculations but unfortunately:

  1. The Clustered Column Chart is not putting April VS October and so on...
  2. Ideally in the table I would like to see only the dates from October 2024 to March 2025 and do a In Season - Out of Season to calculate the difference

(Picture here (StackOverflow upload picture is broken right now))

Naturally I provide you the files to play with:

EDIT:

After discussion with Leith, which is very nice, I' trying to start the months from May but it doesn't works:

vs_Date_names = 
    SWITCH(TRUE(),
        /* Out of Season */
        MONTH('Compare'[date]) = 5 && YEAR('Compare'[date]) = 2024, "1st month: May 2024 vs Nov 2024",
        MONTH('Compare'[date]) = 6 && YEAR('Compare'[date]) = 2024, "2st month: Apr 2024 vs Dec 2024",
        MONTH('Compare'[date]) = 7 && YEAR('Compare'[date]) = 2024, "3st month: Jun 2024 vs Jan 2025",
        MONTH('Compare'[date]) = 8 && YEAR('Compare'[date]) = 2024, "4st month: Jul 2024 vs Feb 2025",
        MONTH('Compare'[date]) = 9 && YEAR('Compare'[date]) = 2024, "5st month: Aug 2024 vs Mar 2025",
        MONTH('Compare'[date]) = 10 && YEAR('Compare'[date]) = 2024, "6st month: Sep 2024 vs Apr 2025",

        /* In of Season */
        MONTH('Compare'[date]) = 11 && YEAR('Compare'[date]) = 2024, "1st month: May 2024 vs Nov 2024",
        MONTH('Compare'[date]) = 12 && YEAR('Compare'[date]) = 2024, "2st month: Apr 2024 vs Dec 2024",
        MONTH('Compare'[date]) = 1 && YEAR('Compare'[date]) = 2025, "3st month: Jun 2024 vs Jan 2025",
        MONTH('Compare'[date]) = 2 && YEAR('Compare'[date]) = 2025, "4st month: Jul 2024 vs Feb 2025",
        MONTH('Compare'[date]) = 3 && YEAR('Compare'[date]) = 2025, "5st month: Aug 2024 vs Mar 2025",
        MONTH('Compare'[date]) = 4 && YEAR('Compare'[date]) = 2025, "6st month: Sep 2024 vs Apr 2025"
    )

Not sure why but it creates a blank bar?


Solution

  • You can first define a DAX calculated column that will help you display In month name vs out of season month name here is one possible DAX code:

    vs_Date_names = 
        SWITCH(TRUE(),
               MONTH('Compare'[date])=4 && YEAR('Compare'[date])=2024,"Apr 2024 vs Oct 2024",
               MONTH('Compare'[date])=5 && YEAR('Compare'[date])=2024,"May 2024 vs Nov 2024",
               MONTH('Compare'[date])=6 && YEAR('Compare'[date])=2024,"Jun 2024 vs Dec 2025",
               MONTH('Compare'[date])=7 && YEAR('Compare'[date])=2024,"Jul 2024 vs Jan 2025",
               MONTH('Compare'[date])=8 && YEAR('Compare'[date])=2024,"Aug 2024 vs Feb 2025",
               MONTH('Compare'[date])=9 && YEAR('Compare'[date])=2024,"Sep 2024 vs Mar 2025",
               MONTH('Compare'[date])=10 && YEAR('Compare'[date])=2024,"Apr 2024 vs Oct 2024",
               MONTH('Compare'[date])=11 && YEAR('Compare'[date])=2024,"May 2024 vs Nov 2024",
               MONTH('Compare'[date])=12 && YEAR('Compare'[date])=2024,"Jun 2024 vs Dec 2025",
               MONTH('Compare'[date])=1 && YEAR('Compare'[date])=2025,"Jul 2024 vs Jan 2025",
               MONTH('Compare'[date])=2 && YEAR('Compare'[date])=2025,"Aug 2024 vs Feb 2025",
               MONTH('Compare'[date])=3 && YEAR('Compare'[date])=2025,"Sep 2024 vs Mar 2025"
               )
    

    This will give you a common column between the dates you want to compare you can adapt the names that are displayed. Now you can replace the X-axis of the Clustered Column Chart and the date column in your by this new created calculated DAX column (vs_Date_names) to get the right clusters. You can also replace Year & Month columns in the table by the new calculated DAX column (vs_Date_names) to get the desired result.

    EDIT : You will first need to modify the two DAX measures to modify the dates like the following:

    In Season = 
    CALCULATE(
        SUM('Compare'[Seasonality]),
        FILTER(
            'Compare',
            'Compare'[date] >= DATE(2024,11,1) &&
            'Compare'[date]  <= DATE(2025,4,31)
        )
    )
    

    and

    Out of season = 
    CALCULATE(
        SUM('Compare'[Seasonality]),
        FILTER(
            'Compare',
            'Compare'[date]  >= DATE(2024,5,1) &&
            'Compare'[date]  <= DATE(2024,10,30)
        )
    )
    

    If you observe the vs_Date_names column you wrote, you will see that the names are not exacty what you want (line 2 is where the mistake is and it impacts the other lines). Here is a modified version that should work:

    vs_Date_names = 
        SWITCH(TRUE(),
            /* Out of Season */
            MONTH('Compare'[date]) = 5 && YEAR('Compare'[date]) = 2024, "1st month: May 2024 vs Nov 2024",
            MONTH('Compare'[date]) = 6 && YEAR('Compare'[date]) = 2024, "2st month: Jun 2024 vs Dec 2024",
            MONTH('Compare'[date]) = 7 && YEAR('Compare'[date]) = 2024, "3st month: Jul 2024 vs Jan 2025",
            MONTH('Compare'[date]) = 8 && YEAR('Compare'[date]) = 2024, "4st month: Aug 2024 vs Feb 2025",
            MONTH('Compare'[date]) = 9 && YEAR('Compare'[date]) = 2024, "5st month: Sep 2024 vs Mar 2025",
            MONTH('Compare'[date]) = 10 && YEAR('Compare'[date]) = 2024, "6st month: Oct 2024 vs Apr 2025",
    
            /* In of Season */
            MONTH('Compare'[date]) = 11 && YEAR('Compare'[date]) = 2024, "1st month: May 2024 vs Nov 2024",
            MONTH('Compare'[date]) = 12 && YEAR('Compare'[date]) = 2024, "2st month: Jun 2024 vs Dec 2024",
            MONTH('Compare'[date]) = 1 && YEAR('Compare'[date]) = 2025, "3st month: Jul 2024 vs Jan 2025",
            MONTH('Compare'[date]) = 2 && YEAR('Compare'[date]) = 2025, "4st month: Aug 2024 vs Feb 2025",
            MONTH('Compare'[date]) = 3 && YEAR('Compare'[date]) = 2025, "5st month: Sep 2024 vs Mar 2025",
            MONTH('Compare'[date]) = 4 && YEAR('Compare'[date]) = 2025, "6st month: Oct 2024 vs Apr 2025"
        )