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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
jnunn
Frequent Visitor

Adding a previous Week column in a calendar

I need some help adding a Previous Week as a column in a calendar.    

I am trying to add a column that flags which week is last week bassed on todays date.  I tried to use the "Date.IsInPreviousWeek" function (formula below) and what I get is True for every row in my table.    

"AddPreviuosWeek = Table.AddColumn(AddCalendarYear, "Previous Week", each Date.IsInPreviousWeek(Date.AddDays(DateTime.FixedLocalNow(), -7)), type text)"

What am I doing wrong?

Is there a better function to use to find which dates are in the previous week?

Thanks

Jeff

1 ACCEPTED SOLUTION

Did you confirm it is type logical? You should see a red x/green checkmark for the data type. It should show up just fine in your tables on the DAX/Visualization side, and you use it in expressions by comparing it to TRUE or FALSE

2020-03-20_9-34-12.png
please mark the answer as a solution if everything is good. Post back with additional questions.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

 

AddPreviuosWeek = Table.AddColumn(AddCalendarYear, 
"Previous Week", 
each Date.IsInPreviousWeek(Date.AddDays(DateTime.FixedLocalNow(), -7)), type text)

 

You are subtracting 7 days from today every time - DateTime.FixedLocalNow() is equivalent to TODAY() in Excel. You want to replace that with the Date column in your calendar table.

 

And it should return a TRUE or FALSE as "type logical" not "type text"

Try this, assuming your date column is called Date (case sensitive):

AddPreviuosWeek = Table.AddColumn(AddCalendarYear, 
"Previous Week", 
each Date.IsInPreviousWeek(Date.AddDays([Date], -7)), type logical)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
jnunn
Frequent Visitor

Thank you. 

This gave me the expected results.  Now there is another issue.  When I apply my changes and leave the editor my new column is showing as all blanks.  I see the T/F values in the editor but not in the DAX side of power BI.  Is there something with this formula that would not allow it to come over.  

Please advise

J

Did you confirm it is type logical? You should see a red x/green checkmark for the data type. It should show up just fine in your tables on the DAX/Visualization side, and you use it in expressions by comparing it to TRUE or FALSE

2020-03-20_9-34-12.png
please mark the answer as a solution if everything is good. Post back with additional questions.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.