Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Sum by date with condition

Hi I am new to power BI and would like to seek for the following advice.

 

Data:

ItemSalesDate
Apple1001/01/2022
Orange2001/01/2022
Lemon1501/01/2022
Apple3001/02/2022
Orange2001/02/2022
Lemon2501/02/2022
Apple1001/03/2022
Orange1501/03/2022
Lemon1001/03/2022
Apple3001/05/2022
Orange3501/05/2022
Lemon2001/05/2022

 

My aim is to have 2 equation. 

Equation 1: Sum up the sales (all item) for that month and 2 month after the selected month.

- for example if I select 1 Jan 2022, the result will be sales 1Jan22 - 31Mar22, which is 155

Remarks: the solution come to my mind is to sum up data from start date + 90days, but I am not sure how to make this equation working.

 

Equaton 2: Same criteria as equation 1 but for specific item

- for example, if I select 1 Jan 2022, the result will be sales for Apple from 1Jan22 - 31Mar22, which is 50

 

I am currently using a timeline slicer, not sure if it works as timeline covered a period of time, if the above equation can only works on date picker (single date selection), please let me know.

 

Thank you.

1 ACCEPTED SOLUTION

Hi,

Thank you for your feedback.

If you only need to have a Month Slicer, I suggest creating a Month Column when creating a Calendar table. I added a Month column into a calendar table in the attached file.

Please check the below picture and the attached file whether it suits your requirement.

 

Jihwan_Kim_0-1663055841279.png

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1663039238681.png

 

Jihwan_Kim_1-1663039250739.png

 

 

Expected measure: = 
CALCULATE (
    SUM ( Data[Sales] ),
    DATESINPERIOD ( 'Calendar'[Date], LASTDATE ( 'Calendar'[Date] ), 3, MONTH )
)

 

Only apple expected measure: = 
CALCULATE ( [Expected measure:], 'Item'[Item] = "Apple" )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi Kim,

 

May you include a month filter as exmaple? I can only show 1 result when a date picked instead of a completed list.

 

Thank you.

Hi,

Thank you for your feedback.

If you only need to have a Month Slicer, I suggest creating a Month Column when creating a Calendar table. I added a Month column into a calendar table in the attached file.

Please check the below picture and the attached file whether it suits your requirement.

 

Jihwan_Kim_0-1663055841279.png

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.