Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello!
I created a measure that returns sales per day for certain products, for a certain period of time:
Sales-Campaign =
CALCULATE(
[Sales],
FILTER( AD_RMPITENSPEDIDOS, AD_RMPITENSPEDIDOS[CODPROD] in VALUES( campaign_itens[Cod Rampap] ) ),
DATESBETWEEN( _Calendario[Data], SELECTEDVALUE( campaigns[camp_start]) , SELECTEDVALUE( campanhas[camp_end] ) )
)
Is it possible to calculate sales for the same period of days and same products in the previous month?
Desired result:
Date | Sales-Campaign | Sales-Campaign-LM |
02/01/2023 | 3000 | 4500 |
02/02/2023 | 5700 | 2000 |
Hi,
It will depend upon the structure of underlying data source. Share data in a format that can be pasted in an MS Excel file.
You could use:
Sales-Campaign-Offset =
CALCULATE(
[Sales],
FILTER( AD_RMPITENSPEDIDOS, AD_RMPITENSPEDIDOS[CODPROD] in VALUES( campaign_itens[Cod Rampap] ) ),
DATESBETWEEN( _Calendario[Data], EDATE(SELECTEDVALUE( campaigns[camp_start])-1) , EDATE(SELECTEDVALUE( campanhas[camp_end] )-1) )
)
But that would still throw an error if your campaign start or end date doesn't exist in the previous month (e.g. if your campaign end date is 31 March EDATE(SELECTEDVALUE( campanhas[camp_end] )-1) is going to throw an error. You could try dealing with that like this, which will sub your selected start and end date for the last day of the previous month if an error is encountered:
Sales-Campaign-Offset =
CALCULATE([Sales],
FILTER( AD_RMPITENSPEDIDOS, AD_RMPITENSPEDIDOS[CODPROD] in VALUES( campaign_itens[Cod Rampap] ) ),
DATESBETWEEN( _Calendario[Data],
IFERROR(EDATE(SELECTEDVALUE(campaigns[camp_start])-1),EODATE(SELECTEDVALUE(
campaigns[camp_start])-1)) ,
IFERROR(EDATE(SELECTEDVALUE(campanhas[camp_end])-1),EODATE(SELECTEDVALUE(
campanhas[camp_end])-1)))
)
User | Count |
---|---|
114 | |
74 | |
57 | |
44 | |
39 |
User | Count |
---|---|
176 | |
125 | |
61 | |
60 | |
58 |