Forum Discussion
Difference between previous week and this week data
Hi ApurvaKhatri
The trick is get an index calculated column to sort Weeks. (You can use power query)
This is the result
And the measures in my case are...
Total Sales = SUM(Sales[Sales])
Total Sales PW = var thisweek = FIRSTNONBLANK(Sales[Index];1) var prevweek = LOOKUPVALUE(Sales[Index];Sales[Index];thisweek-1) return CALCULATE([Total Sales];ALL(Sales[Date]);Sales[Index] = prevweek)
Variance = [Total Sales] - [Total Sales PW]
I hope this helps
Regards
BILASolution
- ApurvaKhatri8 years agoHelper III
Thanks for the solution. But in my case, sales is a measure so its not working
- ApurvaKhatri8 years agoHelper III
Hello BILASolution
In my case, Total Salea is a measure.
Will this solution still work?
Thanks,
Apurva Khatri
- BILASolution8 years agoSolution Specialist
- ApurvaKhatri8 years agoHelper III
Hi BILASolution and Ashish_Mathur
I cannot share the exact data.
But I would give you an idea hat I am trying to acheive
Table : Sample
Columns : PrincipalBalance (It is amount 1000, 24000, 32448, 767778) , Date (It contains everyday dates), Number(it has values negative, positive i.e 0.76, 0.4,-8.6, 75.0, 23, 5.4, 4.3 .... ), ID
I have created calculated column :
Day Of week = FORMAT ( Sample[Date], "dddd" ) - To extract the week day names from Date column
Date Select = if(Sample[Date] = "Wednesday",Sample[Date],Blank()) - I need the sum(PrincipalBalance) every wednesday for entire week starting Thursday to Wednesday. i.e 10/25/2017 - Wednesday sum(balance) from 10/19/2017 - 10/25/2017.
I have created measures:
Current = CALCULATE(COUNT(Sample[lD]),FILTER(Sample,Sample[Number]< 1))
1-2 Weeks = CALCULATE(COUNT(Sample[lD]),FILTER(Sample,Sample[Number] < 3))
3-4 Weeks = CALCULATE(COUNT(Sample[lD]),FILTER(Sample,Sample[Number] < 5))
5+ Weeks = CALCULATE(COUNT(Sample[lD]),FILTER(Sample,Sample[Number] >= 5))
Sum = Current + 1-2 Weeks + 3-4 Weeks +( 5+ Weeks)
Data Display
Matrix
Rows: Date Select
Column: Months(Date)
Values: Sum
Now I need the difference between 25th Oct and 18th Oct, 18th Oct and 11th Oct and so on...
Number Balance Date
0.00 1000 10/24/2017
0.00 2000 10/16/2017
1.00 7000 10/10/2017
0.00 1000 10/27/2017
0.00 2000 10/17/2017
1.10 5000 10/24/2017
-6.57 3500 10/10/2017
17.61 2500 10/2/2017I need to acheive this.
Please Help.
Thanks alot for your time
- Ashish_Mathur8 years agoSuper User
Hi ApurvaKhatri,
No one here is intested in your actual data. Dummy your dataset and then share the result of that dummy dataset. The dataset that you paste here should be such that can be easily copied into an Excel file.
- ApurvaKhatri8 years agoHelper III
Hello Ashish_Mathur
Number Balance Date 0 61625 10/20/2017 6:15 0 67219.92 10/15/2017 6:15 2.26 59320.41 10/10/2017 6:15 0.22 82904.55 10/25/2017 6:15 0 89217.92 10/18/2017 6:15 0 58800 10/19/2017 6:15 0 89868.48 10/20/2017 6:15 -1 74000 10/15/2017 6:15 0 68400 10/20/2017 6:15 0 72450 10/2/2017 6:15 4 70300 10/11/2017 6:15 0 68400 10/12/2017 6:15 0 91383.16 10/18/2017 6:15 48 91575 10/14/2017 6:15 1 70775 10/22/2017 6:15 -0.01 88788.74 10/14/2017 6:15 -0.79 60823.19 10/8/2017 6:15 0 71225 10/13/2017 6:15 0 72150 10/11/2017 6:15 0 71250 10/21/2017 6:15 0 69837.5 10/10/2017 6:15 47.15 97570.8 10/12/2017 6:15 0 62400 10/25/2017 6:15 1 60450 10/26/2017 6:15 I am unable to attach the excel file.