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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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.



Follow on LinkedIn
@ 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!:
Power BI Cookbook Third Edition (Color)

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.