cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

How to make Chart with STDDev, Upper, Lower Control Limit ADAPT to Date Slicer and Date Heirarchy

Hi everyone,

 

I have DAX formulas for upper and lower control limits (LCL) that are not dynamic based on date / date heirarchy. My question is, does anyone know a way to easily make it dynamic toward dates or do I need to create 3 seperate DAX calculations with month, week, date to get it to change?

 

As you can see the LCL and UCL are not dynamic, they work on the overall data but if we look to month and week, they should not have the same LCL and UCL.

 

Screenshot (62)_LI.jpg

Screenshot (61)_LI.jpg

 

LCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALL('OPEN CASES'))
        -3*CALCULATE(STDEV.P('CASES'[OPENCASES]),ALL('OPEN CASES'))

 

 

UCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALL('OPEN CASES')) 
        +3*CALCULATE(STDEV.P('CASES'[OPENEMMACASES]),ALL('OPEN CASES'))

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: How to make Chart with STDDev, Upper, Lower Control Limit ADAPT to Date Slicer and Date Heirarch

Hi @nataliengarces ,

 

The ALL statement returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table. Meaning that when you calculate that in you table you are picking up all the values from your table and ignoring the filter context in this case for date.

 

You need to change your measure using an ALLSELECTED.

LCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'))
        -3*CALCULATE(STDEV.P('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'))

 

Be aware that making use of this function with the full table can bring you some misscalculations so you may consider on pinpointing to the selected value of dates something similar to:

 

LCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'[Date Column]))
        -3*CALCULATE(STDEV.P('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'[Date Column]))

If one of this does not return expected result can you please share a sample file.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: How to make Chart with STDDev, Upper, Lower Control Limit ADAPT to Date Slicer and Date Heirarch

Hi @nataliengarces ,

 

The ALL statement returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied. This function is useful for clearing filters and creating calculations on all the rows in a table. Meaning that when you calculate that in you table you are picking up all the values from your table and ignoring the filter context in this case for date.

 

You need to change your measure using an ALLSELECTED.

LCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'))
        -3*CALCULATE(STDEV.P('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'))

 

Be aware that making use of this function with the full table can bring you some misscalculations so you may consider on pinpointing to the selected value of dates something similar to:

 

LCL = 
CALCULATE(
    AVERAGE('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'[Date Column]))
        -3*CALCULATE(STDEV.P('CASES'[OPENCASES]),ALLSELECTED('OPEN CASES'[Date Column]))

If one of this does not return expected result can you please share a sample file.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog:

Power BI em Português





View solution in original post

Highlighted
Helper III
Helper III

Re: How to make Chart with STDDev, Upper, Lower Control Limit ADAPT to Date Slicer and Date Heirarch

Yes using ALLSELECTED on a Date Column worked perfectly! Thank you!

Highlighted
Super User III
Super User III

Re: How to make Chart with STDDev, Upper, Lower Control Limit ADAPT to Date Slicer and Date Heirarch

@nataliengarces ,

 

Glad I could help, please don't forget to mark the correct answer so other can be helped.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog:

Power BI em Português





Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors