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

Frequent Visitor

## Current Month vs Previous Months

Hi Team,

Here is the task, I have 6 Months data, January to June, I have to show the number of customers in the current month vs total number of customers from January to May.

I'm trying to create a measure but that is not working as expected.

Current Month Total Customer = CALCULATE(COUNT('Customer list'[Customer Name]), FILTER(ALL('Customer list'), [Month] = MONTH(TODAY())))

Previous Months Total Customer = CALCULATE(COUNT('Customer list'[Customer Name]), FILTER(ALL('Customer list'), [Month] < MONTH(TODAY())))

3 REPLIES 3
Solution Sage

You said, 'not working as expected', so what's wrong? Result is incorrect or there are some errors?

Your Month column is text amd you are comparing it with MONTH(TODAY())) which is a number output. At first convert month name to month number.

Then your both formula seems to work well:

Hope it helps.

Super User

Hello @Anshu_Joshi ,

I believe you are using Month from different table. If that is not the case, then your formula should work. I tried to create same measures at my end and they are working. Can you please share the same data and the outputs you are getting.

In my case you can see below screenshots for excel calculation and Power BI outputs as well:

sum of sales from 1st Jan to 31 May in Excel is as below which is 7982:

Measure and output in Power BI are as below:

Current Month as per excel is 710:

Current Month as per Power BI:

If Previous Months DAX is not working then you can use it as below as well:

``Sales Before Current Month = CALCULATE(SUM(Data[Sales]),ALL(Data),FILTER(Data,Data[Month]<MONTH(TODAY())))``

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

Frequent Visitor

Hello @Kishore_KVN ,

Actually I'm having a date column from which I created a Month column.

I don't have numbers to sum but Customers name to count.

For the above Image I used this Measure:

Current Month Total Customer = CALCULATE(COUNT('Customer list'[Customer Name]), FILTER(ALL('Customer list'), [Month] = MONTH(TODAY())))
and
Previous Months Total Customer = CALCULATE(COUNT('Customer list'[Customer Name]), FILTER(ALL('Customer list'), [Month] < MONTH(TODAY())))