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

RANKX on selected field parameter

Is there anyone who have succeded creating a dynamic RANKX based on a Parameter Field selection?

Today I have a this "static" Rank measure:

Rank BU and Gross Revenue = RANKX(all(DimOrganisation[BU]), [Gross Revenue],,DESC)
 
But I would be able to create a Rank, based on two parameters I have created as Field Parameters:
Rank Dynamic = RANKX(all("Parameter field selected"), "Parameter measure selected",,DESC)
 
Is that possible?
2 ACCEPTED SOLUTIONS

Hi, @nhniniras 

Are you referring to this kind of ‘Field-parameters’ ?

Currently, PowerBI does not support direct use of field parameters in measure.

 

Best Regards,
Community Support Team _ Eason

View solution in original post

Hello @nhniniras ,

 

I was also looking a solution for this in the web, and then I realized that "field parameter" is only for Power Bi to understand it, but at the end is about the columns you have included in your fields.

 

So what I did is to created a measure with an if statement according to the Order of my fields names and is working perfectly (I used the measure to show a specific number of customers in a visual according to a slicer, hence the switch true):

IF(SELECTEDVALUE(localCustomers[localCustomers Order]) = 0
    ,SWITCH(TRUE()
        ,RANKX(
            ALLSELECTED('Dim Customer'[LOCAL_CUSTOMER_NAME])
            ,[businessMetricCP]
            ,,,Dense
        ) <= SelectedTop,
        1
    )
    ,SWITCH(TRUE()
        ,RANKX(
            ALLSELECTED('Dim Customer'[CUSTOMER_KEY])
            ,[businessMetricCP]
            ,,,Dense
        ) <= SelectedTop,
        1
    )
)
 
Hope can help others with the same doubts.

View solution in original post

5 REPLIES 5
nhniniras
Frequent Visitor

Thank you for your suggestion, I relly appreciate your help 🙂


I am not sure I understand it correctly, but as far as I understand I can't use your "what is selected" as a part of my "Rank dynamic" measusre.
Your suggestion is another approach of solving the problem, including a new measure "what is selected" and then you will put that measure into a kind of Switch function -  Have I understood it correctly?

Hi, @nhniniras 

Are you referring to this kind of ‘Field-parameters’ ?

Currently, PowerBI does not support direct use of field parameters in measure.

 

Best Regards,
Community Support Team _ Eason

Hello @nhniniras ,

 

I was also looking a solution for this in the web, and then I realized that "field parameter" is only for Power Bi to understand it, but at the end is about the columns you have included in your fields.

 

So what I did is to created a measure with an if statement according to the Order of my fields names and is working perfectly (I used the measure to show a specific number of customers in a visual according to a slicer, hence the switch true):

IF(SELECTEDVALUE(localCustomers[localCustomers Order]) = 0
    ,SWITCH(TRUE()
        ,RANKX(
            ALLSELECTED('Dim Customer'[LOCAL_CUSTOMER_NAME])
            ,[businessMetricCP]
            ,,,Dense
        ) <= SelectedTop,
        1
    )
    ,SWITCH(TRUE()
        ,RANKX(
            ALLSELECTED('Dim Customer'[CUSTOMER_KEY])
            ,[businessMetricCP]
            ,,,Dense
        ) <= SelectedTop,
        1
    )
)
 
Hope can help others with the same doubts.

Hi and sorry for my late respons, but thank you very much.
I think we more or less ended up with the same solution with some IF and Swithc functions 🙂

In my solution I ended up writing a bunch of measures and used the Switch function to find the "parameter" measure the user wants create a Top X on.

 
------- 1. My Switch function
Measure TopX selected =
SWITCH (
    SELECTEDVALUE ( 'ParameterTopX'[Parameter_TopX Fields] ),
    "'ALL_Measures'[Top X BU]",
        [Top X BU]
            / CALCULATE (
                [Measure selected],
                ALLSELECTED ( DimOrganisation_project[BU_Initial] )
            ),
    "'ALL_Measures'[Top X Company]",
        [Top X Company]
            / CALCULATE (
                [Measure selected],
                ALLSELECTED ( DimOrganisation_project[ReportCompanyDescription] )
            ),
    "'ALL_Measures'[Top X Customer]",
        [Top X Customer]
            / CALCULATE ( [Measure selected], ALLSELECTED ( Customer_Bridge[Customer] ) ),
 
---- 2. create measures for all "parameter" measures used in Switch function to filter Top X (number of Top X ranks the user wants to see)
Top X BU =
IF ( [Rank BU] <= 'TopXSeries'[TopXValue], [Measure selected] )
 
---- 3. create the Rank function
Rank BU =
IF (
    HASONEVALUE ( DimOrganisation_project[BU_Initial] ),
    RANKX (
        ALLSELECTED ( DimOrganisation_project[BU_Initial] ),
        [Measure selected]
    )
)
 
 I don't know if it could have been made easier, but it works as it should - so thank you all for your input.
 
amitchandak
Super User
Super User

@nhniniras , You can get what is selected like this

example

What is selected = maxx(filter(;]'Axis Slicer', 'Axis Slicer'[Axis Slicer Order]= SELECTEDVALUE('Axis Slicer'[Axis Slicer Order])),'Axis Slicer'[Axis Slicer])

 

better to have two measure and switch that

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.

Top Solution Authors