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
Anonymous
Not applicable

Display the result of friday as yesterday for monday

Hello Community,

 

I have a measure which calculate the count of insepection for yesterdaty based on today's date: 

Number of UD taken Yesterday =
CALCULATE (
DISTINCTCOUNT('INSPECTION LOTS DATA - Header'[Inspection lot])) ,
ALL ( 'INSPECTION LOTS DATA - Header'[UD Code] ),
USERELATIONSHIP ( 'DIM_Calendar'[Date], 'INSPECTION LOTS DATA - Header'[UD code date] ),
'DIM_Calendar'[Date] =TODAY()-1),
'INSPECTION LOTS DATA - Header'[UD Code] <> BLANK ()
)
 
But since I don't have Data saturday and sunday, i want to display the data of friday as yesterday of monday 
 
Could you help me please ?
 
Thanks
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understand correctly about your data model and your calendar table, but please try to write a measure something like below, for inserting a condition that is not including saturday and sunday.

 

Number of UD taken Yesterday =
VAR _today =
    TODAY ()
VAR _yesterdayexceptweekends =
    MAXX (
        FILTER (
            'DIM_Calendar',
            'DIM_Calendar'[Date] < _today
                && 'DIM_Calendar'[Weekdayname] <> "Saturday"
                && 'DIM_Calendar'[Weekdayname] <> "Sunday"
        ),
        'DIM_Calendar'[Date]
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'INSPECTION LOTS DATA - Header'[Inspection lot] ),
        ALL ( 'INSPECTION LOTS DATA - Header'[UD Code] ),
        USERELATIONSHIP ( 'DIM_Calendar'[Date], 'INSPECTION LOTS DATA - Header'[UD code date] ),
        'DIM_Calendar'[Date] = _yesterdayexceptweekends,
        'INSPECTION LOTS DATA - Header'[UD Code] <> BLANK ()
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you for you help 🙂

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understand correctly about your data model and your calendar table, but please try to write a measure something like below, for inserting a condition that is not including saturday and sunday.

 

Number of UD taken Yesterday =
VAR _today =
    TODAY ()
VAR _yesterdayexceptweekends =
    MAXX (
        FILTER (
            'DIM_Calendar',
            'DIM_Calendar'[Date] < _today
                && 'DIM_Calendar'[Weekdayname] <> "Saturday"
                && 'DIM_Calendar'[Weekdayname] <> "Sunday"
        ),
        'DIM_Calendar'[Date]
    )
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'INSPECTION LOTS DATA - Header'[Inspection lot] ),
        ALL ( 'INSPECTION LOTS DATA - Header'[UD Code] ),
        USERELATIONSHIP ( 'DIM_Calendar'[Date], 'INSPECTION LOTS DATA - Header'[UD code date] ),
        'DIM_Calendar'[Date] = _yesterdayexceptweekends,
        'INSPECTION LOTS DATA - Header'[UD Code] <> BLANK ()
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.