Forum Discussion
calculate value between 2 date
- 1 year ago
Hello Mike91 ,
Firstly you need to setup the Calendar Table for getting the result you are for to start with you can try the below meaures and replace it with the Concern tables and columns whoch you..
If you already have the promotion period selected via a slicer, you can calculate the sales during the promotion using the datesbetween like below
SalesDuringPromotion =
CALCULATE(
SUM(Sales[SalesAmount]),
DATESBETWEEN(
'Calendar'[Date],MIN('Sales'[PromotionStartDate]),MAX('Sales'[PromotionEndDate])))You can calculate sales for the 4 weeks before the promotion with the Dateadd function..
SalesBeforePromotion =
CALCULATE(
SUM(Sales[SalesAmount]),
DATESBETWEEN(
'Calendar'[Date],DATEADD(MIN('Sales'[PromotionStartDate]), -28, DAY),MIN('Sales'[PromotionStartDate]) - 1))If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!
Thank You
Dharmendar S
Thanks for your help, but not working, i'm working with calendar table connected with my sales table, in the sales table one column contain the name of promotion, my goal is see the the 28 days before the start and the 28 before the end, in the same visualization with promotion period. i tried with date add and min and max but when i use the slicer to change promotion to see, the days after and before not showing, i can't understand what filter i need remove to see that results.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523