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
SH-VE
Helper IV
Helper IV

last week number as a slicer

Hi All  , 

I need to create a report which procides compliance %  for last week.

For this I need help to create a dynamic filter ("last promise week #" here). I am not able to use MAX as date syntax . 

any help, very much appreciated!

 

Snag_1ea0d2f.png

 

Thanks,

9 REPLIES 9
mahoneypat
Employee
Employee

If you add a Date table, you can make a calculated column like this one to identify the current week.  You can then use it in your measure to filter to just that week (IsCurrentWeek =1).  Or you can use it in the slicer filter.

 

IsCurrentWeek = var weekstart = TODAY() - WEEKDAY(TODAY()) +1
var weekstop = weekstart +6
return IF('Date'[Date]>=weekstart && 'Date'[Date] <=weekstop, 1, 0)
 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat , I do have a date table in my model. However, for the report , I need the last promise week # as the end result. A promise week # can have two or more dates included .

 

Also, should a relationship be created with the date table you mentioned for the syntax to work?

 

I tried creating this syntax:

 

Snag_62e693a.png

 

Thanks,

From the picture of your model, your date table was not obvious.  From the pic in your last post, the FILTER function returns a table so can't be used in the return of your measure.  You need to also do an aggregation to return a scalar result.  

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


lbendlin
Super User
Super User

Do you have a week number column in your Calendar/Dates table?

Yes , "promise week" in the snapshot is the week #.

Thanks,

A Calendar/Dates table requires contiguous dates across your entire fact date range plus a little more depending on what date math you are doing.  "promise week"  is a fact table attribute.  Required, but not sufficient.  Can you show your data model?

Hi @lbendlin , here is snapshot of the data model

Snag_24196bb.png

 Thanks.

that's just one data source in Power Query.  The data model in Power BI shows how your queries (data sources) are related. It's the third icon on the left.

 

lbendlin_0-1598395152163.png

 

Hi @lbendlin ,

 

I am reusing an original built report. Its huge report with 20 tables, I am only 2 tables from it. please see below

 

Snag_5d730eb.png

 

Snag_5d818fa.png

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.

Top Solution Authors