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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MMartinez
Regular Visitor

Monthly percent change per customer per month

Hello,

 

I'm new to Power BI, but I think it's great.  I am trying to calculate monthly percent change per customer per month for three colums (monthly volume, monthly transaction count, monthly avg transaction amount)

 

I have a column the following columns within my table:

-Customer Name

-Month

-Year

-Monthly Volume

-Monthly Transaction Count

-Monthly Average Transaction Amount

-Month, Year

 

Any help would be much appreciated.  Thanks.

1 ACCEPTED SOLUTION

@MMartinez

 

We can use VAR to define a variable and it is local to the expression in which we define them. Make sure you don’t miss any bracket.

Monthly percent change per customer per month_5.jpg

 

Best Regards,

Herbert

View solution in original post

8 REPLIES 8

Welcome.  There is a lot to learn. To do this type of calc, you will need a calendar table. Read about that here 

http://exceleratorbi.com.au/power-pivot-calendar-tables/

 

If if you want to make fast progress, you could consider reading my book http://xbi.com.au/learndax   It will help you learn quickly and efficiently. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

I actually ordered your book yesterday and I expect it to to arrive soon.  Hopefully, I'll get to the point were I can figure this out on my own soon.  My data looks like the following and goes from Jan 2015 to Jun 2016:

 

Customer Name | Month | Year | Monthly Volume | Monthly Trans. Count | Monthly Trans Average

Client 1                  Jan        2015       20,000                 30                                  667

Client 2                  Jan        2015       10,000                 20                                  500

Client 3                  Jan        2015       25,000                 10                                  2,500

Client 1                  Feb       2015       100,000               40                                  2,500

Client 2                  Feb       2015       150,000               70                                  2,143

Client 3                  Feb        2015      75,000                 100                                750

 

Is adding a calendar table my best option?  If so, what's the DAX formula that will get me the monthly percent change numbers I'm after?  Thanks again for any help.

@MMartinez

 

You’d better to add a calendar table to use the Time Intelligence Functions. Then we can add a new Date column in your table with following formula and change its Data Type to “Date”.

Date = Table1[Month] & " " & Table1[Year]

Monthly percent change per customer per month_1.jpg

 

The next step is to create two new columns in the Calendar table with following formulas. Select YearMonth column and make it sort by YearMonth_Num column as below.

YearMonth = FORMAT( 'Date'[Date], "mmm yyyy" )
YearMonth_Num = YEAR( 'Date'[Date] ) * 100 + MONTH( 'Date'[Date] )

Monthly percent change per customer per month_2.jpg

 

Create a relationship between two tables.

 

Monthly percent change per customer per month_3.jpg

 

Create two measures with following formulas. We should also be able to get monthly percent change for transaction count and avg transaction amount by replacing the [Monthly Volume] column.

Vol_PreMonth = CALCULATE( SUM( Table1[Monthly Volume] ), PREVIOUSMONTH( 'Date'[Date] ) )
Vol_Monthly%Change = 
VAR Vol_CurrentMonth =
    CALCULATE ( SUM ( Table1[Monthly Volume] ) )
RETURN
    (
        IF (
            NOT ( ISBLANK ( [Vol_PreMonth] ) ),
            DIVIDE ( Vol_CurrentMonth - [Vol_PreMonth], [Vol_PreMonth] )
        )
    )

Monthly percent change per customer per month_4.jpg

 

Best Regards,

Herbert

@v-haibl-msft Thank you for the tip.

 

The last part of what you suggest a bit confusig for me though:

 

Vol_Montly%Change=

VAR Vol CurrentMonth=

  Calculate(SUM(Table1[Monthly Volume]))

RETURN

   (

        IF  (

              NOT(ISBLANK (Vol_PreMonth)),

              DIVIDE (Vol_CurrentMonth - [Vol_PreMonth], [Vol_PreMonth])

)

)

 

Is this a single formula to be used in a single measure?

 

 

 

 

 

@MMartinez

Yes, it's a single formula of monthly percent change per customer per month for "monthly volume" column.

 

Best Regards,

Herbert

http://community.powerbi.com/t5/user/viewprofilepage/user-id/11355

Maybe I'm reading the formula wrong, but I tried entering it as a measure and it wasn't calculating.

Having two = signs, the RETURN, and the VAR is what I don't get.

@MMartinez

 

We can use VAR to define a variable and it is local to the expression in which we define them. Make sure you don’t miss any bracket.

Monthly percent change per customer per month_5.jpg

 

Best Regards,

Herbert

@v-haibl-msft

 

This is what I needed.  It works.  Thank you for the help.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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