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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ab_99
Frequent Visitor

Divide Current Matrix Value by Reference Value in same Matrix (trend calculation)

Hi,

 

I have a matrix, with years as rows and months as columns. 

I want to perform a trend calculation. Herefore, I need a reference value - in this case it is the first number of the earliest month+year, 1.834,00.

Now I want to divide the upcoming months by this reference value, e. g.:

  • for 2023-02: 8.086,50/1.834,00
  • for 2024-01: 1.376,00/1.834,00

ab_99_0-1725976989245.png

But again, the reference value must be for all other upcoming years the first value of the earliest date period.

 

Can someone help me with that? 

 

Thank you very much in advance!

 

1 ACCEPTED SOLUTION
quantumudit
Super User
Super User

Hello @ab_99 

It would have been helpful to have a sample data file for reference; however, I created some sample data based on the screenshot you shared. Using that, I have developed a DAX measure that should be of assistance.

 

Below is the screenshot of the sample data I prepared:

quantumudit_0-1725986416139.png

Here is the simple DAX measure for the natural values with a simple summation aggregation:

Total Values = SUM(TrendCalcTable[Value])

Since you haven't specified what exactly to do with the earliest month and year value, such as whether to divide it by the reference value or keep it as is, I have created two measures to accommodate both conditions.

 

This is the DAX measure that does not divide the reference value by the earliest year and month value in the matrix:

TrendCalc_opt1 = 
VAR _earliestYear =
    CALCULATE ( MIN ( TrendCalcTable[Year] ), ALL ( TrendCalcTable ) )
VAR _earliestMonth =
    CALCULATE ( MIN ( TrendCalcTable[Month] ), ALL ( TrendCalcTable ) )
VAR _refValue =
    CALCULATE (
        [Total Values],
        FILTER (
            ALL ( TrendCalcTable ),
            TrendCalcTable[Year] = _earliestYear
                && TrendCalcTable[Month] = _earliestMonth
        )
    )
RETURN
    IF (
        SELECTEDVALUE ( TrendCalcTable[Year] ) = _earliestYear
            && SELECTEDVALUE ( TrendCalcTable[Month] ) = _earliestMonth,
        [Total Values],
        DIVIDE ( [Total Values], _refValue )
    )

 

Here is the DAX measure that divides the reference value by all the values in the matrix. We simply need to remove the IF condition from the RETURN statement.

TrendCalc_opt2 = 
VAR _earliestYear =
    CALCULATE ( MIN ( TrendCalcTable[Year] ), ALL ( TrendCalcTable ) )
VAR _earliestMonth =
    CALCULATE ( MIN ( TrendCalcTable[Month] ), ALL ( TrendCalcTable ) )
VAR _refValue =
    CALCULATE (
        [Total Values],
        FILTER (
            ALL ( TrendCalcTable ),
            TrendCalcTable[Year] = _earliestYear
                && TrendCalcTable[Month] = _earliestMonth
        )
    )
RETURN
DIVIDE ( [Total Values], _refValue )

Here is the screenshot that shows the result:

quantumudit_1-1725986743908.png

Here is the Power BI file for your reference: Power BI File (Link expires on Sep 12, 2024) 

 

Best Regards,
Udit

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍

🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
Visit My Linktree: LinkTree

View solution in original post

1 REPLY 1
quantumudit
Super User
Super User

Hello @ab_99 

It would have been helpful to have a sample data file for reference; however, I created some sample data based on the screenshot you shared. Using that, I have developed a DAX measure that should be of assistance.

 

Below is the screenshot of the sample data I prepared:

quantumudit_0-1725986416139.png

Here is the simple DAX measure for the natural values with a simple summation aggregation:

Total Values = SUM(TrendCalcTable[Value])

Since you haven't specified what exactly to do with the earliest month and year value, such as whether to divide it by the reference value or keep it as is, I have created two measures to accommodate both conditions.

 

This is the DAX measure that does not divide the reference value by the earliest year and month value in the matrix:

TrendCalc_opt1 = 
VAR _earliestYear =
    CALCULATE ( MIN ( TrendCalcTable[Year] ), ALL ( TrendCalcTable ) )
VAR _earliestMonth =
    CALCULATE ( MIN ( TrendCalcTable[Month] ), ALL ( TrendCalcTable ) )
VAR _refValue =
    CALCULATE (
        [Total Values],
        FILTER (
            ALL ( TrendCalcTable ),
            TrendCalcTable[Year] = _earliestYear
                && TrendCalcTable[Month] = _earliestMonth
        )
    )
RETURN
    IF (
        SELECTEDVALUE ( TrendCalcTable[Year] ) = _earliestYear
            && SELECTEDVALUE ( TrendCalcTable[Month] ) = _earliestMonth,
        [Total Values],
        DIVIDE ( [Total Values], _refValue )
    )

 

Here is the DAX measure that divides the reference value by all the values in the matrix. We simply need to remove the IF condition from the RETURN statement.

TrendCalc_opt2 = 
VAR _earliestYear =
    CALCULATE ( MIN ( TrendCalcTable[Year] ), ALL ( TrendCalcTable ) )
VAR _earliestMonth =
    CALCULATE ( MIN ( TrendCalcTable[Month] ), ALL ( TrendCalcTable ) )
VAR _refValue =
    CALCULATE (
        [Total Values],
        FILTER (
            ALL ( TrendCalcTable ),
            TrendCalcTable[Year] = _earliestYear
                && TrendCalcTable[Month] = _earliestMonth
        )
    )
RETURN
DIVIDE ( [Total Values], _refValue )

Here is the screenshot that shows the result:

quantumudit_1-1725986743908.png

Here is the Power BI file for your reference: Power BI File (Link expires on Sep 12, 2024) 

 

Best Regards,
Udit

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudo 👍

🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
Visit My Linktree: LinkTree

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.