Reply
M_Chris
Frequent Visitor

Key Figures Sheet - Measures in columns and rows

Dear all, 

 

I am working with a large and given data model in our company. My target is to create a flexible key figures sheet. Here is a short extract of some columns in the model. 

 

Type of DataKPIValue
Forecast1Revenues100
Forecast2Revenues110
ActualsRevenues50
Actuals PYRevenues45
Forecast1Orders120
Forecast2Orders105
ActualsOrders95
Actuals PYOrders50
Forecast1Profit30
Forecast2Profit35
ActualsProfit25
Actuals PYProfit15

 

I would like to create a measure for each KPI and for each Type of data so that I can flexible calculate with it every month. 

 

The result should look pretty much like this:

 Actuals PYActualsForecast1Forecast2delta to FC PM
Orders     
Revenues     
Profit     
Profit margin%     

 

I was able to generate the KPI's by using an if formula. What would be an efficient way to calculate the type of data measures?

 

Many thanks for your support!

3 ACCEPTED SOLUTIONS
VahidDM
Super User
Super User

Hi

  • To efficiently create your key figures sheet with KPIs as rows and Types of Data as columns, you can use a dynamic measure within a Matrix visual. Here's how you can achieve this:
  1. Use a Matrix Visual
  • Rows: Place the KPI field.
  • Columns: Place the Type of Data field.
  • Values: Use a dynamic measure (explained below).
  1. Create a Dynamic Measure
  • This measure will display the correct value based on the KPI and Type of Data in the current context:

 

KPI Value = VAR CurrentKPI = SELECTEDVALUE('YourTable'[KPI]) VAR CurrentType = SELECTEDVALUE('YourTable'[Type of Data]) RETURN SWITCH( TRUE(), CurrentKPI = "Profit margin%", DIVIDE( CALCULATE( SUM('YourTable'[Value]), 'YourTable'[KPI] = "Profit", 'YourTable'[Type of Data] = CurrentType ), CALCULATE( SUM('YourTable'[Value]), 'YourTable'[KPI] = "Revenues", 'YourTable'[Type of Data] = CurrentType ) ), SUM('YourTable'[Value]) )

 

  • Explanation:
  • CurrentKPI and CurrentType: Capture the KPI and Type of Data in the current cell of the Matrix.
  • SWITCH Function: Determines what to calculate based on CurrentKPI.
    • If Profit margin%, it calculates Profit ÷ Revenues for the current Type of Data.
    • Otherwise, it sums the Value for the current KPI and Type of Data.
  • 3. Calculate Delta to Forecast Previous Month
  • Add a measure for the "delta to FC PM":

 

Delta to FC PM = VAR Actuals = CALCULATE( SUM('YourTable'[Value]), 'YourTable'[Type of Data] = "Actuals" ) VAR Forecast1 = CALCULATE( SUM('YourTable'[Value]), 'YourTable'[Type of Data] = "Forecast1" ) RETURN Actuals - Forecast1

 

  1. Update the Matrix Visual
  • Columns: Modify your columns to include the calculated "Delta to FC PM" by adding it to your data or creating a custom column in the Matrix.
  • Values: Ensure the KPI Value measure is used.
  1. Format the Values
  • Percentage Format: For the Profit Margin %, set the format to percentage.
    • Right-click the KPI Value measure in the Fields pane.
    • Choose Format and select Percentage for the Profit Margin% row.

Benefits of This Approach

  • Dynamic and Scalable: Automatically adjusts for new KPIs or Types of Data without creating multiple measures.
  • Efficient: Reduces the number of measures needed, simplifying maintenance.
  • Flexible Calculations: Allows for custom calculations like Profit Margin and Delta within the same measure.
  • Example Output

KPI

Actuals PY

Actuals

Forecast1

Forecast2

Delta to FC PM

Orders

50

95

120

105

(Actuals - FC1)

Revenues

45

50

100

110

(Actuals - FC1)

Profit

15

25

30

35

(Actuals - FC1)

Profit margin %

33.3%

50%

30%

31.8%

N/A

Notes

  • Replace 'YourTable' with the actual name of your data table.
  • Ensure your data model properly reflects relationships if needed.
  • The Delta to FC PM measure assumes you're comparing Actuals to Forecast1; adjust as necessary.

 

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

Appreciate your Kudos!! 

LinkedIn|Twitter|Blog |YouTube 

View solution in original post

Hi @M_Chris 

 

You need to update the current switch and add Format function to change the format of data for the items you wanna see them in % format.

Like this:

KPI Value =
VAR CurrentKPI =
    SELECTEDVALUE ( 'YourTable'[KPI] )
VAR CurrentType =
    SELECTEDVALUE ( 'YourTable'[Type of Data] )
RETURN
    SWITCH (
        TRUE (),
        CurrentKPI = "Profit margin%",
            FORMAT (
                DIVIDE (
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Profit",
                        'YourTable'[Type of Data] = CurrentType
                    ),
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Revenues",
                        'YourTable'[Type of Data] = CurrentType
                    )
                ),
                "Percent"
            ),
        SUM ( 'YourTable'[Value] )
    )

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

Appreciate your Kudos!! 

 

LinkedIn|Twitter|Blog |YouTube 

 

View solution in original post

Hi @M_Chris 

 

Try this:

 

KPI Value =
VAR CurrentKPI =
    SELECTEDVALUE ( 'YourTable'[KPI] )
VAR CurrentType =
    SELECTEDVALUE ( 'YourTable'[Type of Data] )
RETURN
    SWITCH (
        TRUE (),
        CurrentKPI = "Profit margin%",
            FORMAT (
                DIVIDE (
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Profit",
                        'YourTable'[Type of Data] = CurrentType
                    ),
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Revenues",
                        'YourTable'[Type of Data] = CurrentType
                    )
                ),
                "0.0%"
            ),
        SUM ( 'YourTable'[Value] )
    )

 

 

Hope this solve your problem and please accept all 3 version of my post as solutions to help others.

Appreciate your Kudos!! 

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

8 REPLIES 8
M_Chris
Frequent Visitor

@VahidDM thank you very much. That is exactly what I have been looking for. 

 

It is working out quiet nice. The only thing I am not yet able to get done is the change of the layout so that the margin appears in percentages. I am only able to change the whole set of data to decimal places but not one single row into percentages. 

 

Cheers and really appreciated. 

 

M_Chris_0-1731071032702.png

 

 

Hi @M_Chris 

 

You need to update the current switch and add Format function to change the format of data for the items you wanna see them in % format.

Like this:

KPI Value =
VAR CurrentKPI =
    SELECTEDVALUE ( 'YourTable'[KPI] )
VAR CurrentType =
    SELECTEDVALUE ( 'YourTable'[Type of Data] )
RETURN
    SWITCH (
        TRUE (),
        CurrentKPI = "Profit margin%",
            FORMAT (
                DIVIDE (
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Profit",
                        'YourTable'[Type of Data] = CurrentType
                    ),
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Revenues",
                        'YourTable'[Type of Data] = CurrentType
                    )
                ),
                "Percent"
            ),
        SUM ( 'YourTable'[Value] )
    )

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

Appreciate your Kudos!! 

 

LinkedIn|Twitter|Blog |YouTube 

 

@VahidDM  great job! I am really impressed. it works awesome. Just one minor thing: currently it shows the percentages with two decimal places. is it possible to include in the format fomular that the percentage should appear with only one decimal place? Of course I will accept this as solution. really appreciated....

Hi @M_Chris 

 

Try this:

 

KPI Value =
VAR CurrentKPI =
    SELECTEDVALUE ( 'YourTable'[KPI] )
VAR CurrentType =
    SELECTEDVALUE ( 'YourTable'[Type of Data] )
RETURN
    SWITCH (
        TRUE (),
        CurrentKPI = "Profit margin%",
            FORMAT (
                DIVIDE (
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Profit",
                        'YourTable'[Type of Data] = CurrentType
                    ),
                    CALCULATE (
                        SUM ( 'YourTable'[Value] ),
                        'YourTable'[KPI] = "Revenues",
                        'YourTable'[Type of Data] = CurrentType
                    )
                ),
                "0.0%"
            ),
        SUM ( 'YourTable'[Value] )
    )

 

 

Hope this solve your problem and please accept all 3 version of my post as solutions to help others.

Appreciate your Kudos!! 

LinkedIn | Twitter | Blog | YouTube 

Hi all,

 

@VahidDM the solution forks very well so far. I was able to create a first key figures sheet. Currently I added a separate column for sorting/ranking reasons of my KPI's which I can change manually in the background. When adding another "Ranking" column my calculcated margins disappear. 

BEFORE:

M_Chris_1-1731413675638.png

 

AFTER (without margins)

M_Chris_2-1731413977493.png

 

I do not understand why the calculcated margins are disappearing because I thought I linked them between KPI and Data Type. 

 

KPI Value =
VAR CurrentKPI = SELECTEDVALUE(EPM[KPI])
VAR CurrentType = SELECTEDVALUE(EPM[Data Type])
RETURN SWITCH(TRUE(),
    CurrentKPI = "Gross profit %", FORMAT(
    DIVIDE(
        CALCULATE(SUM(EPM[Value]), EPM[KPI] = "Gross profit",EPM[Data Type] = CurrentType),
        CALCULATE(SUM(EPM[Value]),EPM[KPI] = "Revenue", EPM[Data Type] = CurrentType)), "0.0%"),       
SUM(EPM[Value]))

 

Do you have any idea with the margins are disappearing when I add the additional ranking column as first column? Any idea how to adjust the DAX?

 

Many thanks

Chris

 

VahidDM
Super User
Super User

Hi

  • To efficiently create your key figures sheet with KPIs as rows and Types of Data as columns, you can use a dynamic measure within a Matrix visual. Here's how you can achieve this:
  1. Use a Matrix Visual
  • Rows: Place the KPI field.
  • Columns: Place the Type of Data field.
  • Values: Use a dynamic measure (explained below).
  1. Create a Dynamic Measure
  • This measure will display the correct value based on the KPI and Type of Data in the current context:

 

KPI Value = VAR CurrentKPI = SELECTEDVALUE('YourTable'[KPI]) VAR CurrentType = SELECTEDVALUE('YourTable'[Type of Data]) RETURN SWITCH( TRUE(), CurrentKPI = "Profit margin%", DIVIDE( CALCULATE( SUM('YourTable'[Value]), 'YourTable'[KPI] = "Profit", 'YourTable'[Type of Data] = CurrentType ), CALCULATE( SUM('YourTable'[Value]), 'YourTable'[KPI] = "Revenues", 'YourTable'[Type of Data] = CurrentType ) ), SUM('YourTable'[Value]) )

 

  • Explanation:
  • CurrentKPI and CurrentType: Capture the KPI and Type of Data in the current cell of the Matrix.
  • SWITCH Function: Determines what to calculate based on CurrentKPI.
    • If Profit margin%, it calculates Profit ÷ Revenues for the current Type of Data.
    • Otherwise, it sums the Value for the current KPI and Type of Data.
  • 3. Calculate Delta to Forecast Previous Month
  • Add a measure for the "delta to FC PM":

 

Delta to FC PM = VAR Actuals = CALCULATE( SUM('YourTable'[Value]), 'YourTable'[Type of Data] = "Actuals" ) VAR Forecast1 = CALCULATE( SUM('YourTable'[Value]), 'YourTable'[Type of Data] = "Forecast1" ) RETURN Actuals - Forecast1

 

  1. Update the Matrix Visual
  • Columns: Modify your columns to include the calculated "Delta to FC PM" by adding it to your data or creating a custom column in the Matrix.
  • Values: Ensure the KPI Value measure is used.
  1. Format the Values
  • Percentage Format: For the Profit Margin %, set the format to percentage.
    • Right-click the KPI Value measure in the Fields pane.
    • Choose Format and select Percentage for the Profit Margin% row.

Benefits of This Approach

  • Dynamic and Scalable: Automatically adjusts for new KPIs or Types of Data without creating multiple measures.
  • Efficient: Reduces the number of measures needed, simplifying maintenance.
  • Flexible Calculations: Allows for custom calculations like Profit Margin and Delta within the same measure.
  • Example Output

KPI

Actuals PY

Actuals

Forecast1

Forecast2

Delta to FC PM

Orders

50

95

120

105

(Actuals - FC1)

Revenues

45

50

100

110

(Actuals - FC1)

Profit

15

25

30

35

(Actuals - FC1)

Profit margin %

33.3%

50%

30%

31.8%

N/A

Notes

  • Replace 'YourTable' with the actual name of your data table.
  • Ensure your data model properly reflects relationships if needed.
  • The Delta to FC PM measure assumes you're comparing Actuals to Forecast1; adjust as necessary.

 

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

Appreciate your Kudos!! 

LinkedIn|Twitter|Blog |YouTube 

M_Chris
Frequent Visitor

I thought it makes sense to have e.g. a calculated measure for the individual KPI"s. like Revenues or Profit so that I can calculate the Profit margin in % afterwards. Therefore I am looking for the DAX formula to create e.g. a separate Measure to show the Profit in the rows across all type of data. I tried with the calculate fucntion so far. 

FreemanZ
Super User
Super User

hi @M_Chris ,

 

as i see, type of data can work well with your KPI measures, what do you mean by "efficient way to calculate the type of data measures"? could you elaborate that?

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)