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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Angel
Resolver III
Resolver III

sales amount difference between two dates

Hi, everyone

 

I have this scenario.

Captura.JPG

I would like to create a measure with sales amount between fecha registro and when a month begins reset to 0.

 

The result would be something like this.

 

                                                            Month(Mes)

      Posting date (fecha registro)                 6                   7

      -------------------------------

       09/05/2016                                     10437             11028

       16/05/2016                                     + 116            +     50  

       23/05/2016                                     +     6            -      12 

       30/05/2016                                     +   28            -      36

 

Is there any way to do that?. Assuming there is a way to do it, can I show %difference too?.

 

Any suggestion will be appreciated.

 

Thanks,

1 REPLY 1
technolog
Super User
Super User

To achieve this, you can use a combination of DAX functions in Power BI. Here's a step-by-step guide:

Cumulative Sales Measure:
First, create a measure that calculates the cumulative sales for each month up to the current date in the context of the visual.

Cumulative Sales =
CALCULATE(
SUM(Table[Sales]),
FILTER(
ALL(Table[fecha registro]),
Table[fecha registro] <= MAX(Table[fecha registro]) &&
MONTH(Table[fecha registro]) = MONTH(MAX(Table[fecha registro]))
)
)
Difference from Previous Date Measure:
To show the difference from the previous date, you can use the following measure:

Sales Difference =
[Cumulative Sales] -
CALCULATE(
[Cumulative Sales],
DATEADD(Table[fecha registro], -1, DAY)
)
Percentage Difference Measure:
To show the percentage difference, you can use the following measure:

% Difference =
IF(
CALCULATE([Cumulative Sales], DATEADD(Table[fecha registro], -1, DAY)) <> 0,
[Sales Difference] / CALCULATE([Cumulative Sales], DATEADD(Table[fecha registro], -1, DAY)),
BLANK()
)
Visualizing the Data:

Drag the fecha registro field to the rows of a matrix visual.
Drag the Month field to the columns of the matrix visual.
Add the Sales Difference and % Difference measures to the values area of the matrix visual.
This will give you a matrix that shows the sales difference for each date by month, and the percentage difference from the previous date.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.