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

to get yesterday date based on today date

Hi -

 

i have syntax formula from another BI Tool below

 

CASE DATENAME('weekday', TODAY())
    WHEN "Monday" THEN DATEADD('day', -4,TODAY())
    WHEN "Tuesday" THEN DATEADD('day', -4,TODAY())
    WHEN "Wednesday" THEN DATEADD('day', -2,TODAY())
    WHEN "Thursday" THEN DATEADD('day', -2, TODAY())
    WHEN "Friday" THEN DATEADD('day', -2, TODAY())
    WHEN "saturday" THEN DATEADD('day', -2, TODAY())
    WHEN "Sunday" THEN DATEADD('day', -3, TODAY())
END

now i want to use in Power BI... i was looking in google, since i am really new in Power BI, so mostly i don't understand 🙂

can you please suggest how to write that logic in power BI?

 

thanks in advance

1 ACCEPTED SOLUTION
evandrocunico
Resolver III
Resolver III

Hi @rezaaditia 

 

create a new column and try this:

 

new_col = SWITCH(WEEKDAY(today();3);0;today()-4;1;today()-4;2;today()-2;3;today()-2;4;today()-2;5;today()-2;6;today()-3)
 
-- weekday(date; return)
return:
-- 1 = sunday is 1 to 7
--  2 = monday is 1 to 7
--  3 = monday is 0 to 6
 
best regards

View solution in original post

2 REPLIES 2
evandrocunico
Resolver III
Resolver III

Hi @rezaaditia 

 

create a new column and try this:

 

new_col = SWITCH(WEEKDAY(today();3);0;today()-4;1;today()-4;2;today()-2;3;today()-2;4;today()-2;5;today()-2;6;today()-3)
 
-- weekday(date; return)
return:
-- 1 = sunday is 1 to 7
--  2 = monday is 1 to 7
--  3 = monday is 0 to 6
 
best regards

thanks @evandrocunico , its working the formula 🙂

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.