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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JohnShepherdAPD
Helper II
Helper II

Rank multiple measures each with different calculations

I have a list of 53 measures that each have a unique calculation but the result of which can be compared to the other measures, I would like to find the Top N amongst these measures

 

KPIPerfSalesMeasureSelection = VAR _selecteditem = SELECTEDVALUE('KPI Performance Measures'[DaxMeasureName])
RETURN
IFERROR(SWITCH (
        _selecteditem,
        "New Retail HD Units Perf.",[New Retail HD Units Perf.],
        "New Retail HD GPU Perf.",[New Retail HD GPU Perf.],
        "New Retail Non-HD Units Perf.",[New Retail Non-HD Units Perf.],
        "New Retail Non-HD GPU Perf.",[New Retail Non-HD GPU Perf.],
        "New Retail PDI Costs per Unit Perf.",[New Retail PDI Costs per Unit Perf.],
        "New Other Income Perf.",[New Other Income Perf.],
        "Used Retail HD Units Perf.",[Used Retail HD Units Perf.],
        "Used Retail HD GPU Perf.",[Used Retail HD GPU Perf.],
        "Used Retail Non-HD Units Perf.",[Used Retail Non-HD Units Perf.],
        "Used Retail Non-HD GPU Perf.",[Used Retail Non-HD GPU Perf.],
        "Used Other income Perf.",[Used Other income Perf.],
        "New Finance & Insurance Cases Perf.",[New Finance & Insurance Cases Perf.],
        "New Finance & Insurance per Case Perf.",[New Finance & Insurance per Case Perf.],
        "Used Finance &Insurance Cases Perf.",[Used Finance &Insurance Cases Perf.],
        "Used Finance & Insurance per Case Perf.",[Used Finance & Insurance per Case Perf.],
        "Used Retail Reconditioning per Unit Perf.",[Used Retail Reconditioning per Unit Perf.],
        "New & Used Extended Warranty GPU Perf.",[New & Used Extended Warranty GPU Perf.],
        "Rental Bikes Gross Profit Perf.",[Rental Bikes Gross Profit Perf.],
        "Sales Personnel Expenses Perf.",[Sales Personnel Expenses Perf.],
        "Sales Non-personnel Expenses Perf.",[Sales Non-personnel Expenses Perf.],
        BLANK ()
    ),0)

 

My problem is, that using this measure takes a very long time to calculate and max out the memory of the visual, is there a better way to select the measures for Top N? 

 

Example KPI:

 

New Retail HD GPU Perf. = ( ( [VS10805C1] / [VS10803C1] ) - ( [VS10805C2] / [VS10803C2] ) ) * [VS10803C1]

 

VS10805 is a reference to a data entry cell and C1 denoted whether it is based on what comparison I need

 

VS10805C1 = (
    CALCULATE (
        [FilteredFactDlrCompC1],
        'Dimension InputReference'[InputReferenceAlternateKey] = "VS10805"
    ) * [CurrencyConvRate]
FilteredFactDlrCompC2 = 
VAR C2Selection =
    IF (
        HASONEVALUE ( Comparison2Options[Comparison 2] ),
        VALUES ( Comparison2Options[Comparison 2] ),
        BLANK ()
    )
RETURN
    SWITCH (
        C2Selection,
        "All Markets",
            CALCULATE (
                [FilteredFactDlrCompC1],
                REMOVEFILTERS ( 'Dimension Dealer'[BMCode] )
            ),
        "Last Year",
            CALCULATE (
                [FilteredFactDlrCompC1],
                SAMEPERIODLASTYEAR ( 'Dimension Date'[FullDateAlternateKey] )
            )
    )

 

 

I cannot use RANKX as the value I want to rank on doesn't exist in a table, only in the visual.

1 ACCEPTED SOLUTION

Instead of having the measure with the huge switch statement in it, create a new fields parameter and add all of the individual measures to that. when a user chooses which measure they want from the slicer it will only calculate the selected value, not all of them. 

rather than having the current measure in the TopN filter and in the matrix, you would use the fields parameter.

View solution in original post

6 REPLIES 6
JohnShepherdAPD
Helper II
Helper II

Hi @johnt75 wow that's a game changer, I didn't know it worked like that thanks so much!

JohnShepherdAPD_0-1660572059529.png

 

JohnShepherdAPD
Helper II
Helper II

Hi @johnt75 I want to show all of the measures in the switch statement in order to find the Top N of all those measures together, the user doesn't want to choose specific KPIs in this report.

I don't see how you can that without massively impacting on performance. 

Do the KPIs need to dynamically adapt to slicers or filters? If not, you could precompute them, and the TOPN, in a calculated column or table. You would still get a performance hit during data refresh, but performance for the end users should be fine

johnt75
Super User
Super User

create a fields parameter and use that both on the visual and as the parameter to TOPN in the visual filter

Hi @johnt75 thanks for your reply, I don't think I was clear with my problem so let me add some more context

I am selecting TopN like this:

JohnShepherdAPD_0-1660569351432.png

JohnShepherdAPD_2-1660569512890.png

 

My visual then looks like this:

JohnShepherdAPD_1-1660569466871.png

Seems simple but this is very slow and will kill the memory usage of the Embedded capacity (A2)

 

Instead of having the measure with the huge switch statement in it, create a new fields parameter and add all of the individual measures to that. when a user chooses which measure they want from the slicer it will only calculate the selected value, not all of them. 

rather than having the current measure in the TopN filter and in the matrix, you would use the fields parameter.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.