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
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...

@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
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.