Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi
I have created a measure as below which gives me the total sales from the 1st April up to today
TOTALSALES = CALCULATE(SUM(SALES[LINEAMOUNT]),
FILTER(SALESLINE,SALESLINE[Depot] = "Depot 1"),
DATESBETWEEN(SALESLINE[DELIVERY DATE],
DATE(2018,4,1),
TODAY()
))
Then I want to get the same sales from the exact period last year so have created a further measure
LY SALES = CALCULATE([TOTALSALES],
SAMEPERIODLASTYEAR('DATE'[Date]))
I cannot figure out why it won't work!! I am sure the SAMEPERIODLASTYEAR is the correct function but it won't give me any result.
Any help would be appreciated.
Solved! Go to Solution.
Hi @Qualube,
The SAMEPERIODLASTYEAR needs a Date context. But the previous measure can't provide that. How did you use the measure? Please try the measure like below.
TOTALSALES =
CALCULATE (
SUM ( SALES[LINEAMOUNT] ),
FILTER ( SALESLINE, SALESLINE[Depot] = "Depot 1" ),
DATESBETWEEN (
SALESLINE[DELIVERY DATE],
DATE ( 2017, 4, 1 ),
EDATE ( TODAY (), -12 ) // "today" of last year.
)
)
Best Regards,
Dale
Hi @Qualube,
The SAMEPERIODLASTYEAR needs a Date context. But the previous measure can't provide that. How did you use the measure? Please try the measure like below.
TOTALSALES =
CALCULATE (
SUM ( SALES[LINEAMOUNT] ),
FILTER ( SALESLINE, SALESLINE[Depot] = "Depot 1" ),
DATESBETWEEN (
SALESLINE[DELIVERY DATE],
DATE ( 2017, 4, 1 ),
EDATE ( TODAY (), -12 ) // "today" of last year.
)
)
Best Regards,
Dale
Hi Dale
Sorry for the delay, the EDATE works (not sure why but I will find out).
Thanks for your help.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 46 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 68 | |
| 31 | |
| 27 | |
| 24 |