Forum Discussion
Dax Sales by Period
Good afternoon everyone,
I am new to dax and need to get the sum of sales as follows:
Sales from day 1 to day 30
Sales from the 31st to the 60th
It's possible?
Thank you
21 Replies
- gregcdFrequent Visitor
Can you attach a screenshot of the data you are working with
- v-huizhn-msft
Microsoft Employee
Hi ricardo_cvo,
It's hard to provide specific solution without sample table. After research, the following thread and articles are useful. In my oppion, you can do your cases after learn them carefully.
filtering-and-comparing-different-time-periods-with-power-bi
Dynamically comparing current totals to last year totals
Total Sales X Custom Period (day 26 current month to day 25 next month)
POWER BI: ModelingThanks,
Angelia- ricardo_cvo
Helper I
Thank you all for the answers:
The data unfortunately can not share, but I am using the formulas below for 30 days and for 60 days:
30 Days = CALCULATE(SUM(FatSales[);FILTER(ALL(FatVenda[Date of Sale]);FatVenda[Date of Sale]>TODAY()- 30))
60 Days = CALCULATE(SUM(FatSales[Date of Sale]);FILTER(ALL(FatVenda[Date of Sale]);FatVenda[Date of Sale]>TODAY()- 61))
Tanks
- Washivale
Resolver V
HI Ricardo,
Check the following if it works:
Sales 1 to 30 Days = CALCULATE([Sum Sales], DATESBETWEEN(dCalendar[Date],MAX(fSales[Date of Sale])-60,MAX(fSales[Date of Sale])-30))
Sales 31 to 60 Days = CALCULATE([Sum Sales], DATESBETWEEN(dCalendar[Date],MAX(fSales[Date of Sale])-30,MAX(fSales[Date of Sale])))
Thanks,
Sandeep
- ricardo_cvo
Helper I
Thanks for the feedback,
I tested the Sales 31 to 60 Days formula that in the example is from 06/13 to 07/07 and is giving 123537,10 how much the value should be 118692.82.
Regards
- Washivale
Resolver V
Hi Ricardo,
Please give it a try with below measures.
Sales 31 to 60 Days =
var ld = CALCULATE ( MAX ( dCalendar[Date] ), ALLSELECTED ( dCalendar[Date] ))
var sd = ld-30
return
CALCULATE([Sum Sales], DATESBETWEEN(dCalendar[Date],sd,ld))Sales 1 to 30 Days =
var ld = CALCULATE ( MAX ( dCalendar[Date] ), ALLSELECTED ( dCalendar[Date] ))
var sd = ld-60
var lp = sd + 30
return
CALCULATE([Sum Sales], DATESBETWEEN(dCalendar[Date],sd,lp))let me know if it works