Forum Discussion
Sales amount previous week (snapshot)
- 9 years ago
Hi
I have used your sample data set and tried to find Sales amount for previous week
Please have a look into it.
First of all you need to model up your data
Modelling Dataset
Model your data into this format please check the Applied Steps for more information basicly Pivoting the salesid from column to row will help.If your data is in such format you can jump to the next step.
Create a Date Dimension
Go to Data View for modelling
Select Modelling
Choose New Table
fire the DAX to create date dimension
DateDim = CALENDAR (DATE (2016, 1, 1), DATE (2016, 12, 31))
Now Select New Column and fire DAX
WeekNumber = WEEKNUM('DateDim'[Date].[Date])
to create weeknumber column into your date dimension.
Relationship
Create a 1 to many Relationship Between your Date Dim Dataset and PBI on basis of Date Dim[Date]=PBI[SnapshotDate]
Create Measure
Right Click on the DateDim Dataset and choose New Measure and Fire this query
Sales Previous Week = CALCULATE(Sum(PBI[Sales]),
FILTER(All('DateDim'), 'DateDim'[WeekNumber] = MIN('DateDim'[WeekNumber])-1 ))Now in Report View
Drop a slicer and put WeekNumber into the field
Now Drop a Chart and Put Sales and the Sales Previous Week into the value Field.
If this fulfills your requirement please like this post
Hi
I have used your sample data set and tried to find Sales amount for previous week
Please have a look into it.
First of all you need to model up your data
Modelling Dataset
Model your data into this format please check the Applied Steps for more information basicly Pivoting the salesid from column to row will help.If your data is in such format you can jump to the next step.
Create a Date Dimension
Go to Data View for modelling
Select Modelling
Choose New Table
fire the DAX to create date dimension
DateDim = CALENDAR (DATE (2016, 1, 1), DATE (2016, 12, 31))
Now Select New Column and fire DAX
WeekNumber = WEEKNUM('DateDim'[Date].[Date])
to create weeknumber column into your date dimension.
Relationship
Create a 1 to many Relationship Between your Date Dim Dataset and PBI on basis of Date Dim[Date]=PBI[SnapshotDate]
Create Measure
Right Click on the DateDim Dataset and choose New Measure and Fire this query
Sales Previous Week = CALCULATE(Sum(PBI[Sales]),
FILTER(All('DateDim'), 'DateDim'[WeekNumber] = MIN('DateDim'[WeekNumber])-1 ))
Now in Report View
Drop a slicer and put WeekNumber into the field
Now Drop a Chart and Put Sales and the Sales Previous Week into the value Field.
If this fulfills your requirement please like this post
If you use the code provided, wouldn't the MIN(WeekNumber) be 1 which effectively zeros out the week number you are filtering on?
Sales Previous Week = CALCULATE(Sum(PBI[Sales]),
FILTER(All('DateDim'), 'DateDim'[WeekNumber] = MIN('DateDim'[WeekNumber])-1 ))