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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
SevsBo
Resolver I
Resolver I

Create a monthly cumulative comparison between target and actual?

I have a goal of creating a monthly comparison between the cumulative yearly Target and cumulative yearly Sales to analyse the gap for the prior month.

 

If I have a table Targets with fixed monthly targets, I can quite easily transform that into Cumulative Monthly Target, before it's loaded in PBI, but what is the best way of getting a cumulative monthly total based on Sales Date?

 

In my mind I'm thinking of doing the following:

  • Convert all Sales Dates to start of month, so we only get one date (or a Month-Year format)
  • Create a calculated table of 12 months, each summing the Sales Vales from the Sales table and adding the results of the prior month to it. So Jan = SUMX..., Feb = Jan + SUMX..., March = Feb + SUMX...
  • Link the Sales & Target tables with a Date Table & use the three to make a KPI visual filtered on last month.

Would that work and is there a more efficient way of doing this?

1 ACCEPTED SOLUTION
v-yohua-msft
Community Support
Community Support

Hi, @SevsBo 

Based on your information, I create sample tables:

vyohuamsft_0-1739956731023.png

vyohuamsft_1-1739956740185.png

vyohuamsft_2-1739956753674.png

 

Create a new column in the Sales table to convert SalesDate to month-year format:

MonthYear = FORMAT(Sales[SalesDate], "YYYY-MM")

vyohuamsft_3-1739956778295.png

 

Create new measures:

Cumulative Sales = 
CALCULATE(
    SUM(Sales[SalesValue]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MAX('Date'[Date])
    )
)
Cumulative Target = 
CALCULATE(
    SUM(Targets[TargetValue]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MAX('Date'[Date])
    )
)

Create a relationship to make sure that the Sales and Targets tables are associated with the Date table through the date column.

Then create a KPI visual, and in the Power BI report view, select the Insert tab, and then select the KPI visual.

vyohuamsft_4-1739956993904.png

 

Drag the Cumulative Sales measure to the Metric field in the KPI visual. Drag the Cumulative Target measure to the Goal field in the KPI visual. Drag the date column from the Date table to the Trend axis field in the KPI visual. Here is my preview:

vyohuamsft_5-1739957021170.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yohua-msft
Community Support
Community Support

Hi, @SevsBo 

Based on your information, I create sample tables:

vyohuamsft_0-1739956731023.png

vyohuamsft_1-1739956740185.png

vyohuamsft_2-1739956753674.png

 

Create a new column in the Sales table to convert SalesDate to month-year format:

MonthYear = FORMAT(Sales[SalesDate], "YYYY-MM")

vyohuamsft_3-1739956778295.png

 

Create new measures:

Cumulative Sales = 
CALCULATE(
    SUM(Sales[SalesValue]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MAX('Date'[Date])
    )
)
Cumulative Target = 
CALCULATE(
    SUM(Targets[TargetValue]),
    FILTER(
        ALL('Date'),
        'Date'[Date] <= MAX('Date'[Date])
    )
)

Create a relationship to make sure that the Sales and Targets tables are associated with the Date table through the date column.

Then create a KPI visual, and in the Power BI report view, select the Insert tab, and then select the KPI visual.

vyohuamsft_4-1739956993904.png

 

Drag the Cumulative Sales measure to the Metric field in the KPI visual. Drag the Cumulative Target measure to the Goal field in the KPI visual. Drag the date column from the Date table to the Trend axis field in the KPI visual. Here is my preview:

vyohuamsft_5-1739957021170.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

rajendraongole1
Super User
Super User

Hi @SevsBo  - you have a Date Table (dimDate) with a continuous range of dates and mark it as a date table in Power BI.

use a DAX measure to calculate cumulative sales up to the last completed month dynamically.

Cumulative Sales =
VAR MaxVisibleDate = MAX('dimDate'[Date])
RETURN
CALCULATE(
SUM(Sales[Sales Amount]),
FILTER(
ALL('dimDate'),
'dimDate'[Date] <= MaxVisibleDate
)
)

 

create another cumulative target measure as below:

 

Cumulative Target =
VAR MaxVisibleDate = MAX('dimDate'[Date])
RETURN
CALCULATE(
SUM(Targets[Target Amount]),
FILTER(
ALL('dimDate'),
'dimDate'[Date] <= MaxVisibleDate
)
)

 

Now you can calclate the Gap = [Cumulative Sales] - [Cumulative Target]

 

To show the KPI only for the last completed month

Last Completed Month Cumulative Sales =
VAR LastMonth = EOMONTH(TODAY(), -1)
RETURN
CALCULATE(
[Cumulative Sales],
'dimDate'[Date] = LastMonth
)

 

Hope this helps. please check and confirm.

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.