Forum Discussion
Getting Value Sum from previous week
- 9 years ago
Sorry Mistake is my side.
Try this
Pre Sales =
var End_Date = MIN('Week Sales'[StartOfWeek]) -1
var Start_Date = End_Date - 6
return
CALCULATE(SUM('Week Sales'[Sales]),DATESBETWEEN('Week Sales'[Date],Start_Date,End_Date),ALLSELECTED('Week Sales'[StartOfWeek]))Small Change in your already existing formula .
Change ALLExcpet into ALLSelected, It should work
If not let me know dude.
Thanks a lot Baskar,
I jusat tried your method but it return the same result as the current week.
I was able to get the different with the following
Differ = VAR PreWeek = CALCULATE( MAX( 'Calendar'[Week] ) ) - 1
return
(IF(CALCULATE( MAX( 'Calendar'[Week] ) )=1,BLANK(),
(SUM('Fact'[Sales])-CALCULATE( SUM( 'Fact'[Sales] ), FILTER( ALLSELECTED('Fact'), WEEKNUM( 'Fact'[Date] ) = PreWeek)))))
Found it in https://community.powerbi.com/t5/Desktop/Week-on-Week-Month-on-Month-Analysis/td-p/79063
But now I have another issue.
As you can see I have mutiple people in the chart and the above method will give provide me all the sales of all no that single person's sales.
I know I can add
WEEKNUM( 'Fact'[Date] ) = PreWeek) && 'Fact'[Name]="Name here"
to correct the filter.
But I was unable to find a way to get the current column name to var currentname
Is there a way to do it?
Can u please share some sample data . I will help u
- Vicentbi9 years agoFrequent Visitor
Strange I do not see where I can attach a file.
I'm attaching it as a photo for now.
Do not know if it works.
This is not the data I was using orgnially but structure should be the same
- Vicentbi9 years agoFrequent Visitor
Welp looks like that did not work.
Please use this link.
https://drive.google.com/open?id=0BybUfI2IKhw7M0NWMlp0bG5VSHc
- Baskar9 years agoResident Rockstar
Do u have Continuos date in your Table ?
- Vicentbi9 years agoFrequent Visitor
I believe so, the Date table is made by Power bi with calendar funcation.