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
FinanceBI
Frequent Visitor

Month-Over-Month on Multiple Items

Hello All,

 

I'm looking to calculate the month-over-month return for multiple investments funds. From my understanding, I cannot use the quick measure because I would need to select one base value, but I'm looking to calculate the month-over-month change for a number of funds. 

 

Is it possible to create calculated columns based on the data in a visual? If not, is it possible to get my query to look like the matrix down below, that way I can create some calculated columns to accomplish my goal?

 

I'm open to any ideas. 

 

Currently, my query is structured like this:

PBIex.PNG

 

I created a matrix that looks like this:

PBIex1.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I attached the pbix file below, but here's what I did:

  • Need a dedicated Calendar/Date table. Small function in Power Query that will create a basic one for you
  • Once that is loaded, be sure to mark the DimDate table as a Date Table.  Need to do this to ensure the time intelligence function below will work correctly. 
  • Relate that to your Fact table.  Will use the DateKey from the DimDate table as your filters (sidebar: you may want to have other dimesion tables for the Name and Strategey since you really dont want to filter fact tables, but if the table is not too big it should work fine)

 

Create these measures:

Just a simple average. 

 

Simple Average = AVERAGE( FactReturn[Monthly Return Rate] )
MoM Change = 
//Checks to see if there is a monthly return
IF ( 
    NOT( 
        ISBLANK([Simple Average])
    ),

//Checks to see of the return is the first in the return stream
//if so, it will return First Date, but can put anything there
    IF(
       CALCULATE( 
           COUNTROWS( FactReturn ), 
            FILTER( 
                ALL( DimDate), 
                DimDate[DateKey] <= max( DimDate[DateKey]))
       ) =1,
        "FirstDate"
    ,

//Assuming their is a return and its not the 1st in the stream
//Takes the average return in current filter context and subtracts
//The return from the previous month 
    [Simple Average] - 
        CALCULATE( 
            [Simple Average], 
            PREVIOUSMONTH ( DimDate[DateKey])
        )
    )
)

Final Matrix:

Final Matrix.png

 

Still the issue what you would wnt to do at the total level. Could be average of the changes, whatever the last change was, or maybe dont even need them. But should be a good start

 

File:

https://1drv.ms/u/s!Amqd8ArUSwDS0zAk-xUYbEuuGXI8

 

View solution in original post

5 REPLIES 5
FinanceBI
Frequent Visitor

Hi all, 

 

I'm looking for the easiest way to calculate month over month change for data structured in the following way. I've tried to use the Time Intelligence Month-over-Month Change quick measure, where Base = Return and Date = Return Date. My date is column is set up as a hierarchy, however, this still doesn't work. 

 

I see some tutorials, but they all seem overly involved for such a simple calculation. Perhaps it would be easier to just use a Python script to edit my query?

 

Fund      Return    Return Date

  A             8%       1/31/2019

  A             7%       2/28/2019

  A             8%       3/31/2019

  B             6%       1/31/2019

  B             6%       2/28/2019

  B             5%       3/31/2019

  C            10%      1/31/2019

  C            11%      2/28/2019

  C            12%      3/31/2019

Anonymous
Not applicable

I attached the pbix file below, but here's what I did:

  • Need a dedicated Calendar/Date table. Small function in Power Query that will create a basic one for you
  • Once that is loaded, be sure to mark the DimDate table as a Date Table.  Need to do this to ensure the time intelligence function below will work correctly. 
  • Relate that to your Fact table.  Will use the DateKey from the DimDate table as your filters (sidebar: you may want to have other dimesion tables for the Name and Strategey since you really dont want to filter fact tables, but if the table is not too big it should work fine)

 

Create these measures:

Just a simple average. 

 

Simple Average = AVERAGE( FactReturn[Monthly Return Rate] )
MoM Change = 
//Checks to see if there is a monthly return
IF ( 
    NOT( 
        ISBLANK([Simple Average])
    ),

//Checks to see of the return is the first in the return stream
//if so, it will return First Date, but can put anything there
    IF(
       CALCULATE( 
           COUNTROWS( FactReturn ), 
            FILTER( 
                ALL( DimDate), 
                DimDate[DateKey] <= max( DimDate[DateKey]))
       ) =1,
        "FirstDate"
    ,

//Assuming their is a return and its not the 1st in the stream
//Takes the average return in current filter context and subtracts
//The return from the previous month 
    [Simple Average] - 
        CALCULATE( 
            [Simple Average], 
            PREVIOUSMONTH ( DimDate[DateKey])
        )
    )
)

Final Matrix:

Final Matrix.png

 

Still the issue what you would wnt to do at the total level. Could be average of the changes, whatever the last change was, or maybe dont even need them. But should be a good start

 

File:

https://1drv.ms/u/s!Amqd8ArUSwDS0zAk-xUYbEuuGXI8

 

Thanks for the help! I got this to work. The attached file was very helpful! 

 

I added a "/[Simple Average]" to the end of the MOM field in the DimDate table to get the month over month percentage change. 

momcalc.PNG

Thanks a bunch for the help!

 

Thanks for the help Nick!! Using your template, I was able to accomplish exactly what I set out to. 

 

This dashboard will be used to validate investment returns that we have to enter by hand. Here is the part that Nick helped me with! 

 

PowerBI_DataValidation_Example.png

Anonymous
Not applicable

awesome! Glad I was able to get you in right direction. Good stuff

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.