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
Anonymous
Not applicable

Choose data, display current week data as well as previous week

Hi Guys,

 

based on a selected date (week) in a slicer (SlicerWeek), I want to display in a table the value of the week, as well as the previous week value.

 

The columns of the table contain the date, formatted as week.

There is a date table, linked to a fact table.

 

In the screenshot you can see the desired result of the table, but I want to select only one week in the Week Slicer and display tow weeks data (there are other visuals that show only the current week value).

PrevPeriod.PNG

 

Regards,

Toddy

 

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Refer if my WOW blogs can help you

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

 

or if want select one period and want to show more than that , then use independent date tbale

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Anonymous
Not applicable

hey, @amitchandak 

Thanks for these very helpful links, but I'm still struggeling with the link to the chosen slicer / week. I'll try to have a dynamic previous week, not the previous week to the actual date

 

 

I have already a measures defined

z_Day_Worked_CW-1 = 
	CALCULATE(
		[z_Day_Worked],
		DATEADD('DIM_Calendar'[CAL_CalendarDay], -7, DAY)
	)

 

Maybe only the filtering is my problem...

 

 

@Anonymous , if you want to select a week, the above links can help. But if you want based on today

 

This Week today =
var _st = today() +-1*WEEKDAY(today(),2)+1 //monday week 
var _end =today()+ 7-1*WEEKDAY(today(),2)
return
CALCULATE(SUM(Sales[Sales Amount]),filter('Date','Date'[Date]>= _st && 'Date'[Date]<=_end )) //use all('Date') if need in filter


Last Week today =
var _st = today() +-1*WEEKDAY(today(),2)+1 -7  //monday week
var _end =today()+ 7-1*WEEKDAY(today(),2) -7
return
CALCULATE(SUM(Sales[Sales Amount]),filter('Date','Date'[Date]>= _st && 'Date'[Date]<=_end )) //use all('Date') if need in filter

 

 

sunday week

today() +-1*WEEKDAY(today(),1)+1

Anonymous
Not applicable

Maybe I explained it wrong, maybe it's just a formatting issue.

 

Base data:

calendar table, with date, year, month, week, first day of week, week rank, ...

fact table, with date related, data to display in several categories

 

1. I want to choose one week in a week slicer

2. I want to display in tabular form the data of chosen week, as well as data from previous week, in total two weeks

PrevWeek_wish.PNG

All rows were calculated measures. All measures were defined for current period, as well as previous period, i.e. Holiday and Holiday_CW-1

 

The displayed table is a matrix visual, measures displayed in rows

In column heading is [Week_of_year]

PrevWeek_Measures.PNG

As you can see, when i'm adding cw-1 measure, it's shown in rows, not in columns and I wasn't able to display it in second column.

So my idea was to filter the week_of_year but also struggeling.

 

 

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