Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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?

1 ACCEPTED SOLUTION

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,

 

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
parry2k
Super User
Super User

@Anonymous Can you explain the problem with sample data? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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

 

Anonymous
Not applicable

Hi Amit,

 

Data added in previous post.  So to clarify, I have a line and column chart with both Week Begin Date and Date along the X axis.  If the visual is on Week Begin Date, I need the measure to show the Weekly Average, but if the user drills to daily level, I need the measure to show the daily average (for previous 5 weeks or previous 35 days).

 
 

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,

 

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Bingo!  This is exactly what I needed.  Thank you!

amitchandak
Super User
Super User

@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
Not applicable

Hi Amit,

 

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.