Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Different measure per drill down level

I have a hierarchy with 2 levels Dates.Weeks and Dates.Days.  I have 2 measures [Weekly Average] and [Daily Average].  I need a new measure to switch between [Weekly Average] and [Daily Average] based on the selected hierarchy level.

 

My problem occurs on Mondays when there is only one value for Dates.Weeks and Dates.Days.

 

I've searched and found the below suggestions, but this does not seem to work for my situation.

 

https://community.powerbi.com/t5/Desktop/Different-measure-per-drill-down-level/m-p/627225

 

Suggestions?

  • Hi Anonymous ,

     

    We can try to create a measure as value field of chart to meet your requirement:

     

    Measure =
    IF (
        ISINSCOPE ( Dates[Days] ),
        CALCULATE ( [Daily Average] ),
        CALCULATE ( [Weekly Average] )
    )

     

    We use ISINSCOPE function to verify current level and calculate different value


    Best regards,

     

     

8 Replies

  • Anonymous , Not sure I got it. But you can create Monday to Sunday week like

    Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
    Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amit,

       

      Yes, that is technically what my Dates.Weeks is.  The "Week Begin Date" starting on Mondays.

  • Anonymous Can you explain the problem with sample data? 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Weekly Average = CALCULATE(SUM(Sales.Sales),
                                             DATESBETWEEN(Dates.Days,

                                                    LASTDATE(Dates.Days)-34,
                                                    LASTDATE(Dates.Days)
                                                                        )
                                                        ) / 5

       

      Daily Average = CALCULATE(SUM(Sales.Sales),
                                             DATESBETWEEN(Dates.Days,

                                                    LASTDATE(Dates.Days)-34,
                                                    LASTDATE(Dates.Days)
                                                                        )
                                                   ) / 35

       

      WeeksDaysSales
      3/23/20203/23/2020110
      3/23/20203/24/2020111
      3/23/20203/25/2020112
      3/23/20203/26/2020113
      3/23/20203/27/2020114
      3/23/20203/28/2020115
      3/23/20203/29/2020116
      3/30/20203/30/2020117
      3/30/20203/31/2020118
      3/30/20204/1/2020119
      3/30/20204/2/2020120
      3/30/20204/3/2020121
      3/30/20204/4/2020122
      3/30/20204/5/2020123
      4/6/20204/6/2020124
      4/6/20204/7/2020125
      4/6/20204/8/2020126
      4/6/20204/9/2020127
      4/6/20204/10/2020128
      4/6/20204/11/2020129
      4/6/20204/12/2020130
      4/13/20204/13/2020129
      4/13/20204/14/2020128
      4/13/20204/15/2020127
      4/13/20204/16/2020126
      4/13/20204/17/2020125
      4/13/20204/18/2020124
      4/13/20204/19/2020123
      4/20/20204/20/2020122
      4/20/20204/21/2020121
      4/20/20204/22/2020120
      4/20/20204/23/2020119
      4/20/20204/24/2020118
      4/20/20204/25/2020117
      4/20/20204/26/2020118
      4/27/20204/27/2020119
      4/27/20204/28/2020120
      4/27/20204/29/2020121
      4/27/20204/30/2020122
      4/27/20205/1/2020123
      4/27/20205/2/2020124
      4/27/20205/3/2020125