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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hedgy123
Frequent Visitor

How to compare individual series values with lower and upper limit measures (anomaly detection)?

Hi,

 

   I have a dataset that contains time series data - sales as a function of time by product and customer.  It looks kind of like this:

 

CustomerProductDateSales
1X2/1/2124
1X2/2/2156
1Z2/3/2132
2Y2/2/21542
2Y2/3/2123

 

   I'd like to flag anomalous sales point that are too large or too low for a given customer for a given product.   So I created measures like this:

  QUARTILE1 = PERCENTILEX.INC(SUMMARIZE(Table,'Table'[Customer],'Table'[Product]),CALCULATE(PERCENTILE.INC('Table'[Sales],0.25)),0.25) 

 

QUARTILE3 = PERCENTILEX.INC(SUMMARIZE(Table,'Table'[Customer],'Table'[Product]),CALCULATE(PERCENTILE.INC('Table'[Sales],0.75)),0.75)

 

IQR = [QUARTILE3]-[QUARTILE1]

LOWER_LIMIT = [QUARTILE1]-1.5*[IQR]

UPPER_LIMIT = [QUARTILE3]+1.5*[IQR]

 

   and now I'd like to compare each individual Sales value with the [LOWER_LIMIT] and [UPPER_LIMIT] for a given customer and a given product.  I can't seem to figure it out.  If I just do a calculated column that compares Table[Sales] with the limits, I always get the same value.  

 

     Could someone please help?  

  

 

2 REPLIES 2
MFelix
Super User
Super User

Hi @hedgy123 ,

 

You cannot  create a calculated column based on a measure. Measures are based on context so the result is variable depending on the values you have on the context, meaning visualizations, filters, and so on.

 

You need to make this based on the values you present you need to apply ALL or ALLSELECTED on the quartile value that will get the same value for every single row then use that has your difference to each of the row value.

 

Can you share based on the values you present what are the values for the quartiles that you need to achieve?


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



Thanks Miguel.  Yes, here's what I'd like to achieve with some sample data:

 

Here's my starting data table:

 

Starting dataStarting data

 

Here's a calculation of the quartiles and upper and lower limits per customer per product

 

Screen Shot 2021-02-15 at 10.54.26 AM.png

 

and here's my desired output: I compare every Sales value with the upper and lower limits for the relevant customer and product, and flag those values that are either lower than the lower limit or larger than the upper limit as outliers:

 

Screen Shot 2021-02-15 at 10.55.52 AM.png

 

It's this last step I am struggling with.   I am a PowerBI beginner, so not sure what you mean by applying ALL or ALLSELECTED on the quartile value?

 

Thanks very much for your help.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.