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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.