Forum Discussion

HOrakova's avatar
HOrakova
Icon for Helper I rankHelper I
1 year ago
Solved

Diff between selected and previous period by week

Hi Experts,

I have [Date] column with only start of the week dates in it. I need to calculate the diff between selected and previous period. There are filters by market, age, gender, brand ect. I added one slicer by period type and one with corresponding dates. The following measure is not showing the latest period and I don't know how to fixed it

 

Last Period =
CALCULATE(
    [Switch KPIs],
    FILTER(
        ALLSELECTED(DATA),
        DATA[Wave] = MAX(DATA[Wave]) - 1
    )
)

Actually if there is better solution I will love to hear it.
Thanks in advance!
  • Hi HOrakova 

     

    Use ALL instead of ALLSELECTED. When filtering the data, only the filtered values are considered unless the previous wave is also included in the filter.

    Please note that since ALL is applied to the whole DATA table, the measure will return the value for that specific week selected for the whole of the table.

     

9 Replies

  • Hi HOrakova 

     

    Use ALL instead of ALLSELECTED. When filtering the data, only the filtered values are considered unless the previous wave is also included in the filter.

    Please note that since ALL is applied to the whole DATA table, the measure will return the value for that specific week selected for the whole of the table.

     

    • HOrakova's avatar
      HOrakova
      Icon for Helper I rankHelper I

      Hi danextian ,
      It is not showing the corrent results with ALL

       It supposed to show 2.20 on the second image in Last period.

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

        Can you please post a sanitized copy of your pbix? There may be peculiarities in your model that we are not aware of. Please also see the attached sample pbix.

  • Use OFFSET(-1) to get the previous period filter context.

     

    Last Period =
    CALCULATE(
        [Switch KPIs],
        OFFSET(-1,ALLSELECTED(DATA[Wave]))
    )
    • HOrakova's avatar
      HOrakova
      Icon for Helper I rankHelper I

      Unfortunately it is not showing any results.

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi HOrakova,

     

    Thank you for reaching out to Microsoft Fabric Community.

     

    Try this below measure, this function will work. 

    previosperiod = CALCULATE([SUMOFVALUES],FILTER(ALL(TEST),TEST[PERIOD]=MAX(TEST[PERIOD])-7))

    Let us know if you need any further assistance.

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

     

    Thanks and regards,

    Anjan Kumar Chippa

    • HOrakova's avatar
      HOrakova
      Icon for Helper I rankHelper I

      Hi v-achippa ,

      Thank you for the solution, but it gives the same results that I copied to Danextian.

       

      Best regards!

      • v-achippa's avatar
        v-achippa
        Icon for Community Support rankCommunity Support

        Hi HOrakova,

         

        Could you please share any sample data or pbix file. So that it will help us to narrow down the issue and provide you the best solution possible. Do not include sensitive information and do not include anything that is unrelated to the issue or question.

         

        Thanks and regards,

        Anjan Kumar Chippa