cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

New Member

## How to add previous month sales to current month sales

Hello all,

I'm trying to compare the YTD sales with the goals on YTD format. This is the idea that I want to present:

I can make a table adding the goal of each month, which then I can graph as the blue line. The table below:

The problem I'm finding is how to add what was sold in Oct (in the image) with Nov, so those sales stack up in Nov, the same with Dec (which should be Oct, Nov and Dec stacked), and so on.

The idea of the graph is to show how deviated the sales are resulting against the final goal amount.

I tried with TOTALYTD, but it won't add up the months' results.

Is there any other function? Or other visualization to achieve this?

Thank you.

1 ACCEPTED SOLUTION
Community Support

You may try this Measure.

YTD venta = CALCULATE(SUM('Table'[Venta]),FILTER(ALL('Table'),'Table'[Px]<=MAX('Table'[Px])))

The result should look like this:

For more details, please refer to the attached pbix file.

Best Regards,

Community Support Team _ Caiyun

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

3 REPLIES 3
Community Support

You may try this Measure.

YTD venta = CALCULATE(SUM('Table'[Venta]),FILTER(ALL('Table'),'Table'[Px]<=MAX('Table'[Px])))

The result should look like this:

For more details, please refer to the attached pbix file.

Best Regards,

Community Support Team _ Caiyun

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Super User

Hi,

For YTD calculation you can use this pattern: CALCULATE(SUM('Table'[Value]),DATESYTD('Calendar'[Date])).

I also recommend checking out SQLBI's article on running totals: https://www.sqlbi.com/articles/computing-running-totals-in-dax/

I hope these will help you to solve your issue and if they do consider accepting this post as a solution and giving it a thumbs up!

Proud to be a Super User!

New Member

Hi ValtteriN,

Thank you for your reply, but that pattern brings the same results as a TOTALYTD.

What is needed is a calculation that can add the previous months sales to the current month:

October should be 39; November should be 181; December 220, as it shows in the third column.

Thank you!

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors