cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Anonymous
Not applicable

## Comparing sales and total units period over period

Hi all,

I'm a bit new in power bi and trying to create a sales analysis report where I'm comparing sales period over period. So, let's suppose if i select January 2022 from a slicer then it gives me a percentage of difference with the last month's (December 2021) value. Please have a look of the image, where i have sales as well as total units.

The data looks like that, This is only a example dataset: -

 Date Marektplace sales Quantity 01.12.2021 Amazon.de 2000 40 02.12.2021 Amazon.de 1000 20 31.12.2021 Amazon.es 500 10 01.01.2022 Amazon.de 1500 15 02.01.2022 amazon.co.uk 3000 50 30.01.2022 Amazon.pl 1000 20 05.02.2022 Amazon.se 600 12 ... ... ... ...

And the result could looks like that.

I tried an approach where i created a measure for last 30 days as well as another measure for last 60 days:

``````TotalSales30Day =
CALCULATE (
SUM (Data[Sale]),
DATESINPERIOD (Data[Date], MAX (Data[Date]), -30, DAY )
)``````
``````TotalSalesprevious30Day =
CALCULATE (
SUM (Data[Sale]),
DATESINPERIOD (Data[Date], MAX (Data[Date]), -60, DAY )
)``````

Then i created a difference out of these, but it didn't give me the right result.

So, any guess what measure could be helpful if i would like to create a percentage difference between one month or selected date to the other month or selected date from the slicer?

Regards,

Ahsan

1 ACCEPTED SOLUTION
Super User

you are possibly overcomplicating things a bit.

``````%change =
var penult = [TotalSales60Day]-[TotalSales30Day]
return divide([TotalSales30Day]-penult,abs(penult),0)``````

see attached.

5 REPLIES 5
Anonymous
Not applicable

@Ibendlin, I already added an example table in the post. Please have a look, whether it works, or do I need to provide a big dataset?. Thanks.

Super User

You may want to rethink your slicer approach but attached is an implementation based on your description.

Anonymous
Not applicable

Hi @lbendlin, thank you for your support. I added two other measures in the file, because, i would like to get the monthly difference in percentage. For example; when i select January 2022 then it gives me a percentage comparison with the last month December 2021.
These measures were used by me but were still not able to get the right result.

``Difference30daysvsprevious30days = CALCULATE('Table'[TotalSales60Day] - 'Table'[TotalSales30Day])``
``% Change = DIVIDE('Table'[TotalSales30Day], 'Table'[Difference30daysvsprevious30days], blank())-1``
Super User

you are possibly overcomplicating things a bit.

``````%change =
var penult = [TotalSales60Day]-[TotalSales30Day]
return divide([TotalSales30Day]-penult,abs(penult),0)``````

see attached.

Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Avoid posting screenshots of your source data if possible.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.