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
Saadii_360
Helper I
Helper I

Slicer to show Current Week by default

HI everyone. 
I want to show Current week as default when user open the report or changes the report page.

Saadii_360_0-1643922194040.png

I want this slicer to show by default whenever user opens the report or changes the report page. when user come backs to the page it should show the sales by current week.
PFB the dax im using currently to show the current week between the weeks,

Saadii_360_1-1643922295702.png

//Current Week Slicer
IF(DMVBICalendarView1[SemCourante]= "courrante", "Courante",
IF(DMVBICalendarView1[SemCourante]= "courrante-1", "Courante",
IF(DMVBICalendarView1[SemCourante]= "courrante-2", "Courante",
IF(DMVBICalendarView1[SemCourante]= "courrante-3", "Courante",
//Merging
DMVBICalendarView1[Semaine Fiscale] &"-"& DMVBICalendarView1[Semaine 2022]))))
Need your help. Thanks in advance.
1 ACCEPTED SOLUTION
v-yetao1-msft
Community Support
Community Support

Hi @Saadii_360 

First you need to create a calculated column to return the week number and put the column in slicer to filter data .

week number=
var _number=WEEKNUM('Table'[Date])
var _today=WEEKNUM(TODAY())
return SWITCH(TRUE(),_number=_today,"Current",FORMAT(_number,"####"))

In the formula above , _number is the week number of each date , _today is the week number of today . When _number is equal to _today , you will get the dates belong to current week and return the value with text “current” .

Then create a measure to sum the value .

total value = SUM('Table'[Value])

The final result is as shown :

Ailsamsft_0-1644980806205.png

I have attached my pbix file , you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

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

2 REPLIES 2
v-yetao1-msft
Community Support
Community Support

Hi @Saadii_360 

First you need to create a calculated column to return the week number and put the column in slicer to filter data .

week number=
var _number=WEEKNUM('Table'[Date])
var _today=WEEKNUM(TODAY())
return SWITCH(TRUE(),_number=_today,"Current",FORMAT(_number,"####"))

In the formula above , _number is the week number of each date , _today is the week number of today . When _number is equal to _today , you will get the dates belong to current week and return the value with text “current” .

Then create a measure to sum the value .

total value = SUM('Table'[Value])

The final result is as shown :

Ailsamsft_0-1644980806205.png

I have attached my pbix file , you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

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

@Saadii_360 , the Issue is not clear.

 

But you need have start of week

 

start week = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1 //Monday
end date= 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)

 

Then you can create a new column like

 

Week Type = Switch( True(),
WEEKNUM("Datedim"[entrydate] ) = WEEKNUM( TODAY() ),"This Week" ,
WEEKNUM("Datedim"[entrydate] ) = WEEKNUM( TODAY() )-1,"Last Week" ,
[Week Name]
)

 

Create these in date table and save on this week. As of now you can not default it using a measure/funtion

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