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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ilearngood
New Member

Sum the Count to Get Month Over Month

 

I have a column "purchase date" that has dates and null/blank values by customer (have another column named "customer").

 

Dates range is 1/1/2014 to 2/13/2017.

 

Goal is to create a column that sums the "purchase date" count of purchases for those that are not null by month to get to month over month differences.  

 

So 'Customer A' count of purchases in Jan 2017 is 25, and 20 in Dec 2016.  I need the new column to calculate the difference of 5.

 

Your assistance is appreciated.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ilearngood,

 

Suppose your dataset is like:
1.PNG

 

Based on this sample data, I created a new table which is filtered without null/blank values.

Filter non blank =
CALCULATETABLE (
    'Count purchase',
    'Count purchase'[Purchase Dates] <> BLANK ()
)

 

 

In this new table, I added two extra columns:

Yer_Month =
'Filter non blank'[Purchase Dates].[Year] & "-"
    & 'Filter non blank'[Purchase Dates].[MonthNo]


Previous Month =
IF (
    'Filter non blank'[Purchase Dates].[MonthNo] <> 1,
    'Filter non blank'[Purchase Dates].[Year] & "-"
        & 'Filter non blank'[Purchase Dates].[MonthNo] - 1,
    'Filter non blank'[Purchase Dates].[Year] - 1
        & "-"
        & 12
)

 

Then, I created another table:

Table1 =
SUMMARIZE (
    'Filter non blank',
    'Filter non blank'[Customer],
    'Filter non blank'[Yer_Month],
    "Previous Month", LASTNONBLANK ( 'Filter non blank'[Previous Month], 1 ),
    "Count Value", COUNT ( 'Filter non blank'[Purchase Dates] )
)

In Table1, I created two calculated columns:

Previous Month Count =
LOOKUPVALUE (
    Table1[Count Value],
    Table1[Yer_Month], Table1[Previous Month],
    Table1[Customer], Table1[Customer]
)

Difference Month Over Month =
Table1[Count Value] - Table1[Previous Month Count]

Below was the result what I got:
2.PNG

 

If I have something misunderstood, please share your sample data and provide more detailed information about your expected output.

 

Best regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ilearngood,

 

Suppose your dataset is like:
1.PNG

 

Based on this sample data, I created a new table which is filtered without null/blank values.

Filter non blank =
CALCULATETABLE (
    'Count purchase',
    'Count purchase'[Purchase Dates] <> BLANK ()
)

 

 

In this new table, I added two extra columns:

Yer_Month =
'Filter non blank'[Purchase Dates].[Year] & "-"
    & 'Filter non blank'[Purchase Dates].[MonthNo]


Previous Month =
IF (
    'Filter non blank'[Purchase Dates].[MonthNo] <> 1,
    'Filter non blank'[Purchase Dates].[Year] & "-"
        & 'Filter non blank'[Purchase Dates].[MonthNo] - 1,
    'Filter non blank'[Purchase Dates].[Year] - 1
        & "-"
        & 12
)

 

Then, I created another table:

Table1 =
SUMMARIZE (
    'Filter non blank',
    'Filter non blank'[Customer],
    'Filter non blank'[Yer_Month],
    "Previous Month", LASTNONBLANK ( 'Filter non blank'[Previous Month], 1 ),
    "Count Value", COUNT ( 'Filter non blank'[Purchase Dates] )
)

In Table1, I created two calculated columns:

Previous Month Count =
LOOKUPVALUE (
    Table1[Count Value],
    Table1[Yer_Month], Table1[Previous Month],
    Table1[Customer], Table1[Customer]
)

Difference Month Over Month =
Table1[Count Value] - Table1[Previous Month Count]

Below was the result what I got:
2.PNG

 

If I have something misunderstood, please share your sample data and provide more detailed information about your expected output.

 

Best regards,
Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (1,277)