Forum Discussion

DutchMark's avatar
DutchMark
Icon for Helper III rankHelper III
1 year ago
Solved

Comparing last 12 months to previous 12 months (partial problem)

I compare the last 12 months with the previous 12 months. 

 

I use 2 measurments:

Revenue this year PM = SUM(KPI_EOL_sync_financial_transactionlines[Revenue])
Revenue LY PM = CALCULATE([Revenue this year PM], SAMEPERIODLASTYEAR('Calendar Table'[Date]))
 
I filter on my Calendar Table.
Where I dynamically determine the last 12 months and so on
 
I get this column diagram. The problem is however even if I select Jan-24, I still see Jan-25 in the label
 
 
This gives the following problem, where I see in the "Full year comaprison" only 2025. I stead of 2024 en 2025 (If I remove the filter I see all the years). How can I fix this?


  • Hi DutchMark,

    We sincerely apologize for the inconvenience caused.

    As the issue is still not yet resolved, we kindly request you to raise an issue at Issues - Microsoft Fabric Community for investigation.
    Otherwise raise a Microsoft support ticket using the link provided below. They will be able to provide specific insights related to your account and potential resolutions.
    Microsoft Fabric Support and Status | Microsoft Fabric

    If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar queries.

    Thank you.

22 Replies

  • That is the expected behavior. SAMEPERIODLASTYEAR does not alter the visible rows; instead, it adjusts the filter context relative to the visible rows. So, if you select the past 12 months in your calendar month bucket, those months will be shown. SAMEPERIODLASTYEAR will then return the values for the corresponding period in the previous year.

    • DutchMark's avatar
      DutchMark
      Icon for Helper III rankHelper III

      Okay but I was expect because it shows both last 12 months and the 12 months before that, that it will show the 2 months in both years. 

      I also have other measurements (that I don't use), but I can not seem to get them in the same Column table next to each other. Any tips? Will that get my desired result? Most important for me is that the "Full year comparison" will show both 2025 en 2024 when I select the month in the column diagram. That's a matrix table by the way.

      Last_12_Months_Revenue =
      VAR CurrentMonth = MAX('Calendar Table'[Current Month])
      RETURN
      IF(
          MAX('Calendar Table'[Date]) <= CurrentMonth &&
          MAX('Calendar Table'[Date]) >= EDATE(CurrentMonth, -12),
          SUM(KPI_EOL_sync_financial_transactionlines[Revenue]),
          BLANK()
      )
      ---
      Previous_12_Month_Window_Revenue =
      VAR CurrentMonth = MAX('Calendar Table'[Current Month])
      VAR WindowStart = EDATE(CurrentMonth, -24)
      VAR WindowEnd = EDATE(CurrentMonth, -12)
      RETURN
      IF(
          MAX('Calendar Table'[Date]) <= WindowEnd &&
          MAX('Calendar Table'[Date]) > WindowStart,
          SUM(KPI_EOL_sync_financial_transactionlines[Revenue]),
          BLANK()
      )





      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        You’ll need to rely on one or more measures that respond to slicer selections, rather than depending on the buckets in your date calendar. Measures can modify the filter context and influence which rows are visible—rows without values in the context of the measure may appear hidden. However, slicers from a related dimension can override that and determine the visible rows.

         

        You can use field parameters to switch between different measures like in the image below.

        Please see the attached sample pbix.

         

    • v-kpoloju-msft's avatar
      v-kpoloju-msft
      Icon for Community Support rankCommunity Support

      Hi DutchMark,

      Apologize for the delayed response. Thanks for the follow-up question. I again reproduced the scenario with my sample data with combo chart diagram. I got this outcome below shown in the image.

      Attached is the .pbix file. Could you kindly review it. If the issue continues, kindly provide more precise sample data along with the expected behaviour. This will help us resolve your issue more efficiently.

      If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

      Thank you for using Microsoft Community Forum.

      • DutchMark's avatar
        DutchMark
        Icon for Helper III rankHelper III

        Thank you, but it really needs to look like the chart I already shared and it doesn't look like that at all. More sample data is not going to help. I need a way to put 2 years next to eacht other per month, like shared in the first chart.

  • Everyone seems to read past what I'm asking and read past what I'm looking for.
    - The filters need to be in the formula
    - If I hover over Jan-25, the previous year needs to show in the LABEL Jan-24 and this year Jan-25
    - Don't forgot the Matrix in the bottom. This is what it's all about. Because I need to be able to select both Jan-24 and Jan-25 seperately to see them next to each other. I don't see that now!

  • v-kpoloju-msft's avatar
    v-kpoloju-msft
    Icon for Community Support rankCommunity Support

    Hi DutchMark,
    Thank you for reaching out to the Microsoft fabric community forum. Additionally, the solution proposed by the super user danextian, is correct according to the thread.

    After thoroughly reviewing the details you provided, I was able to reproduce the scenario, and it worked on my end. I have used it as sample data on my end and successfully implemented it.    

    Output:


    If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

    Thank you for using Microsoft Community Forum.