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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
learner03
Post Partisan
Post Partisan

Error with Output

I have created this measure to point to orders closed wthin 48 hors for previous day-
This measure is not givingcorrect output where it says count Number of "Yes".
What is the error here? I want count of order closed yesterday and that has Yes in the column.
I have a coloumn that has YES and NO for orders completed within 48 hours.
Closed within 48 Hrs =
VAR CurrentDate= MAX('Calendar'[Date])
VAR Prev_Day =
CALCULATE(MAX('Calendar'[Date]), FILTER('Calendar', 'Calendar'[Date] < CurrentDate && 'Calendar'[If work day]=1))
VAR Trans_Previous_Day =
CALCULATE(
COUNT('3PL_Fulfilment'[Document Number]), 'Calendar'[Date] = Prev_Day)

Var fortyeightHrs=CALCULATE( Trans_Prvious_Day, '3PL_Fulfilment'[Completed in 48 hours]="Yes")
 
RETURN
fortyeightHrs
+0
1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @learner03 

 

Try this one

Closed within 48 Hrs =
VAR CurrentDate =
    MAX ( 'Calendar'[Date] )
VAR Prev_Day =
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Date] < CurrentDate
                && 'Calendar'[If work day] = 1
        )
    )
VAR fortyeightHrs =
    CALCULATE (
        COUNT ( '3PL_Fulfilment'[Document Number] ),
        ALL ( 'Calendar' ),
        'Calendar'[Date] = Prev_Day,
        '3PL_Fulfilment'[Completed in 48 hours] = "Yes"
    )
RETURN
    fortyeightHrs + 0

 

Your Trans_Previous_Day is a variable which already has a definite value before evaluating fortyeightHrs, as a result its value will not be changed when put in CALCULATE function. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @learner03 

 

Try this one

Closed within 48 Hrs =
VAR CurrentDate =
    MAX ( 'Calendar'[Date] )
VAR Prev_Day =
    CALCULATE (
        MAX ( 'Calendar'[Date] ),
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Date] < CurrentDate
                && 'Calendar'[If work day] = 1
        )
    )
VAR fortyeightHrs =
    CALCULATE (
        COUNT ( '3PL_Fulfilment'[Document Number] ),
        ALL ( 'Calendar' ),
        'Calendar'[Date] = Prev_Day,
        '3PL_Fulfilment'[Completed in 48 hours] = "Yes"
    )
RETURN
    fortyeightHrs + 0

 

Your Trans_Previous_Day is a variable which already has a definite value before evaluating fortyeightHrs, as a result its value will not be changed when put in CALCULATE function. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@learner03 , this will have a problem if only one date is selected, try like

 

 

 

VAR Trans_Previous_Day =
CALCULATE(
COUNT('3PL_Fulfilment'[Document Number]), filter(all('Calendar') , 'Calendar'[Date] = Prev_Day))

 

 

refer last non continuous day

This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])))
Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Work Date cont Rank]=max('Date'[Work Date cont Rank])-1))

 

Last Day Non Continuous = CALCULATE([sales],filter(ALLSELECTED('Date'),'Date'[Date] =MAXX(FILTER(ALLSELECTED('Date'),'Date'[Date]<max('Date'[Date])),'Date'[Date])))

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak can you please check the var fortyeighthrs line ,will it have count or count rows function as it is not counting number of rows where the value in column says "yes"

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors