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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Set default week date dimension in tabel

Hello Power BI community

I have trouble with calculating default week by using Isfiltered (im not sure this is the right way to do)

 

I want my data from my table show the lastest 10 weeks as default, however, I also allow users to use the Week Filter in the left corner and select weeks that earlier than the lastest 10 weeks.


This is my column week so far : 

Year-Week vis true = RIGHT(DIM_DATE[Year-Week vis],2)
 

KhanhTu_1-1623328900577.png

 

Thanks you 

 

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

Hi @Anonymous 

You can try to build an unrelated table to build the week slicer and build measures to calculate the value in matrix.

My Sample:

YearWeek is a caluclated column.

 

YearWeek = YEAR(Sales[Date])*100+WEEKNUM(Sales[Date],2)

 

1.png

Slicer table:

 

Table = VALUES(Sales[YearWeek])

 

Build a slicer by this table and build measures to calculate the value as below.

 

Value = 
VAR _SelectValue = VALUES('Table'[YearWeek])
VAR _CURRENTYearWeek = YEAR(TODAY())*100+WEEKNUM(TODAY(),2)
VAR _RESULT1 = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[YearWeek] in _SelectValue))
VAR _RESULT2 = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[YearWeek]>_CURRENTYearWeek-10))
RETURN
IF(ISFILTERED('Table'[YearWeek]),_RESULT1,_RESULT2)

 

Result:

By default my matrix will show values in last 10 weeks.

3.png

It can show the week I select in slicer as well.

4.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

View solution in original post

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

You can try to build an unrelated table to build the week slicer and build measures to calculate the value in matrix.

My Sample:

YearWeek is a caluclated column.

 

YearWeek = YEAR(Sales[Date])*100+WEEKNUM(Sales[Date],2)

 

1.png

Slicer table:

 

Table = VALUES(Sales[YearWeek])

 

Build a slicer by this table and build measures to calculate the value as below.

 

Value = 
VAR _SelectValue = VALUES('Table'[YearWeek])
VAR _CURRENTYearWeek = YEAR(TODAY())*100+WEEKNUM(TODAY(),2)
VAR _RESULT1 = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[YearWeek] in _SelectValue))
VAR _RESULT2 = CALCULATE(SUM(Sales[Sales]),FILTER(Sales,Sales[YearWeek]>_CURRENTYearWeek-10))
RETURN
IF(ISFILTERED('Table'[YearWeek]),_RESULT1,_RESULT2)

 

Result:

By default my matrix will show values in last 10 weeks.

3.png

It can show the week I select in slicer as well.

4.png

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

 

amitchandak
Super User
Super User

@Anonymous 

You can create a week type in you table and use that. You can default on last 10 weeks

 

Week Type = Switch( True(),
[start week]<=Today() && [end date]>=Today()-70,"Last 10 Week" ,
[Week Name]
)

 

 

Other columns

 

Week Start = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Number = WEEKNUM([Date],2)
Week = if('Date'[Week Number]<10,'Date'[Year]*10 & 'Date'[Week Number],'Date'[Year]&'Date'[Week Number])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hello @amitchandak

Thanks you for your answer but this is not what im looking for :

KhanhTu_4-1623330471641.png

 

I want an output of every single week for the last 10 weeks like this below

KhanhTu_5-1623330533584.png

And still keep my week filtered if I needed to find weeks that further than last 10 weeks.


 

 

 




Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.