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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Dashboard_Dev
Frequent Visitor

Trouble calculating the orders and filled within each quarter

I'm some what new at PBI.

 

I'm trying to figure out how many orders were placed and also filled within each quarter. I do have a slicer for the Quarter on the report. I'm really stumped as to how to go about getting the calculations.  Any help would be appreciated.

 

Order dateFilled Date
06/08/202307/26/2023
06/09/202307/24/2023
04/27/202307/20/2023
05/24/202307/10/2023
06/01/202307/03/2023
05/25/202306/20/2023
03/08/202306/15/2023
05/01/202306/15/2023
01/24/202306/09/2023
06/08/202306/08/2023
04/05/202305/31/2023
03/28/202305/24/2023
03/14/202305/16/2023
03/02/202305/08/2023
03/01/202305/03/2023
02/06/202305/01/2023
02/17/202304/28/2023
04/20/202304/27/2023
02/25/202304/27/2023
03/30/202304/18/2023
03/16/202303/30/2023
02/21/202303/16/2023
01/31/202303/10/2023
02/09/202303/10/2023
01/12/202302/17/2023
02/08/202302/08/2023
02/07/202302/07/2023
03/02/2023 
03/27/2023 
04/18/2023 
04/20/2023 

 

UPDATE

I actually came up with a solution.  I created a column for the quarter for order date and another for filled date. Then I added a conditional column to compare the two columns and return a value, 1 if the orders were placed and filled within the same quarter and 0 if they weren't. Then just added the value of the column in the visual.  I can't believe how simple the solution was and how much I was over thinking and complicating this.

3 REPLIES 3
Dangar332
Super User
Super User

hi, @Dashboard_Dev 

 

(1)

if your slicer data(quarter no) present with same table then use below code

result =
var quarterdata = SELECTEDVALUE('your table'[or qua])
var ordercount = CALCULATE(COUNT('your table'[Filled Date]),QUARTER('your table'[Filled Date])=quarterdata,ALL('your table'[or qua]))
var filledcount = CALCULATE(COUNT('your table'[Order date]),QUARTER('your table'[Order date])=quarterdata,ALL('your table'[Filled Date]))
return  ordercount-filledcount
 
in you data negative value also come as a result measure. you can convert to positive using abs function like below
result =
var quarterdata = SELECTEDVALUE('your table'[or qua])
var ordercount = CALCULATE(COUNT('your table'[Filled Date]),QUARTER('your table'[Filled Date])=quarterdata,ALL('your table'[or qua]))
var filledcount = CALCULATE(COUNT('your table'[Order date]),QUARTER('your table'[Order date])=quarterdata,ALL('your table'[Filled Date]))
return  ABS(ordercount-filledcount)
Dangar332_2-1696748599511.png

 


 


 (2)if your slicer data present in another table you try this
result1 =
var quarterdata = SELECTEDVALUE('Table (2)'[quarter])
var ordercount = COUNTX(FILTER('your table',QUARTER('your table'[Order date])=quarterdata),'your table'[Order date])
var filledcount = COUNTX(FILTER('your table',QUARTER('your table'[Filled Date])=quarterdata),'your table'[Filled Date])
return  ordercount-filledcount
Dangar332_0-1696748403992.png

 

in you data negative value also come as a result1-measure. you can convert to positive using abs function 


Below measure help you to calculate count only those which orderd and filled in same quarter
result2=
var quarterdata = SELECTEDVALUE('your table'[or qua])
var ordercount = CALCULATE(COUNT('your table'[Filled Date]),QUARTER('your table'[Filled Date])=quarterdata)
var filledcount = CALCULATE(COUNT('your table'[Order date]),QUARTER('your table'[Order date])=quarterdata)
return  ordercount-filledcount
 
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your kudos.

Thank you, but even when I changed the names to the actual table names there were multiple syntax errors.

hi, @Dashboard_Dev 

 

please refer This .pbix file in which i mention all things which help you.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.