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
IAM
Helper III
Helper III

Measure to highlight created Yesterday, but 3 days on Monday

Hi all,

 

Is there a clean measure (so without many if statements) for the following?

 

When a order is created Yesterday, I want them showing in my table. But on a Monday, I want to see the orders that are created Friday, Saturday and Sunday.

 

Can anyone help me figure out a efficient measure for this?

 

Table : Export

Column : Date Created

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @IAM ,

 

Monday shows orders from the previous Friday to the previous Sunday, the rest (including Saturday and Sunday) shows orders from the previous day?

Please new a measure like:

Measure = 
VAR _today = TODAY()
VAR _weekday = WEEKDAY(_today,2)
VAR _order_date = SELECTEDVALUE('Table'[Date])
VAR _result = 
SWITCH(
    TRUE(),
    _weekday=1 && _order_date>=_today-3&&_order_date<=_order_date-1,1,
    _weekday<>1 && _order_date=_today-1,1
)
RETURN
_result

This metric is then used as a filter for table visuals and configured as such.

vcgaomsft_0-1675840142719.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
v-cgao-msft
Community Support
Community Support

Hi @IAM ,

 

Monday shows orders from the previous Friday to the previous Sunday, the rest (including Saturday and Sunday) shows orders from the previous day?

Please new a measure like:

Measure = 
VAR _today = TODAY()
VAR _weekday = WEEKDAY(_today,2)
VAR _order_date = SELECTEDVALUE('Table'[Date])
VAR _result = 
SWITCH(
    TRUE(),
    _weekday=1 && _order_date>=_today-3&&_order_date<=_order_date-1,1,
    _weekday<>1 && _order_date=_today-1,1
)
RETURN
_result

This metric is then used as a filter for table visuals and configured as such.

vcgaomsft_0-1675840142719.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors