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
vipett
Helper II
Helper II

Slicer to set tolerances for calcuation

I have a table with a lot of orders with their respective Estimated shipping dates and actual delivery dates and today I have a report that shows which orders are shipped on time (or before). Below is the calculated formula I have for this 

 

OnTime = IF(OR(SalesOrdersDist[Requesteddate]=0,SalesOrdersDist[Earliest delivery date]=0),"",IF(SalesOrdersDist[Earliest delivery date].[Date]<SalesOrdersDist[Requesteddate].[Date],"Yes","no"))
 
This works fine, however, I would like to have a slicer where the user can select exact same shipping date (or earlier) or consider everything shipped 2 days later, 5 days later or 7 days later to be on time.
Of course I can create three new columns for this, but I would like to have it more dynamic as the same principle might apply to other places in my report.
Essentially it could look like this:
OnTime+2 = IF(OR(SalesOrdersDist[Requesteddate]=0,SalesOrdersDist[Earliest delivery date]=0),"",IF(SalesOrdersDist[Earliest delivery date].[Date]<SalesOrdersDist[Requesteddate].[Date]+2,"Yes","no"))
but I would like to avoid that...
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @vipett ,

 

You will need to create a table contains 2, 5 and 7 as a column then use this column as slicer.

Using selectedvalue() function could get the selected slicer value.

https://docs.microsoft.com/en-us/dax/selectedvalue-function .

At last modify the formula change "+2" to "+selectedvalue('slicer'[days])".

 

Best Regards,

Jay

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

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @vipett ,

 

You will need to create a table contains 2, 5 and 7 as a column then use this column as slicer.

Using selectedvalue() function could get the selected slicer value.

https://docs.microsoft.com/en-us/dax/selectedvalue-function .

At last modify the formula change "+2" to "+selectedvalue('slicer'[days])".

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Greg_Deckler
Super User
Super User

@vipett Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

The table looks like this 

SalesOrderNumberNumber of deliveriesEarliest delivery dateLast delivery dateEarliest Estimated dateLast Estimated dateTtl backorderOTOTIFRequesteddate
60110512021-11-15 00:002021-11-15 00:002021-11-19 00:002021-11-19 00:000YesYes2021-11-19 00:00
60046812021-09-24 00:002021-09-24 00:002021-09-24 00:002021-09-24 00:000nono2021-08-23 00:00
60098812021-11-02 00:002021-11-02 00:002021-11-05 00:002021-11-05 00:000nono2021-10-22 00:00
60098212021-11-02 00:002021-11-02 00:002021-11-05 00:002021-11-05 00:000nono2021-10-22 00:00
60118812021-11-10 00:002021-11-10 00:002021-11-05 00:002021-11-05 00:000nono2021-11-05 00:00
60022112021-07-27 00:002021-07-27 00:002021-07-27 00:002021-07-27 00:000nono2021-07-23 00:00
60042012021-08-14 00:002021-08-14 00:002021-08-13 00:002021-08-13 00:000nono2021-08-13 00:00
60094312021-10-08 00:002021-10-08 00:002021-10-08 00:002021-10-08 00:000nono2021-10-08 00:00
60043712021-09-09 00:002021-09-09 00:002021-09-07 00:002021-09-07 00:000nono2021-08-19 00:00
60077712021-09-27 00:002021-09-27 00:002021-09-27 00:002021-09-27 00:000nono2021-08-26 00:00

 

OT is calculated like this:

OT = IF(OR(SalesOrdersDist[Requesteddate]=0,SalesOrdersDist[Earliest delivery date]=0),"",IF(SalesOrdersDist[Earliest delivery date].[Date]<SalesOrdersDist[Requesteddate].[Date],"Yes","no"))
 
OTIF is virutally the same, but instead looks at Last delivery date instead of earliest..
 
So when I create a table in my report, and look at the share between "Yes" and "No", I get a feeling for how much is delivered on Time. 
But users want to add a tolerance, for instance that we say that deliveries 7 days after requested is still ok, then order 600221 in the example above would be considered on time.
But some areas have +7 days as OK, some areas have +0 days as ok, some have +2, etc etc.
 
So instead of calculating many columns with all tolerances built in, I would like to have a matrix in my report that shows what is the On Time performance, originally it is with +0 days as accepted, but there should be a slicer where you can click on 2, 5, 7,etc to change the tolerance.
Almost like a what-if scenario - "Ok my On Time performance is 50%, but what if I consider everything shipped no later than 2 days after the requested date as On time", and then the user changes the slicer, and the numbers are updated.
 
 
 

 

 

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.