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
Anonymous
Not applicable

DAX Formula: Dynamic Index on Selection of slicer in Chart

Hi All,

 

  I want to have a index column/measure which will calculate dynamic on selection of slicer in charts. I want it to be reset to 1 on any selection.

 

  Any suggestion..

 

Thanks,

SuPBI1.PNGScreen1.PNGScreen2.PNGScreen3.PNG

First 2 screens are using an index in source itself where it doesn't change in run time but the last one changes on run time using a measure but I miss ranks in between.

1 ACCEPTED SOLUTION

Hi @Anonymous

 

You need to specify the last parameter of RANKX i.e TIES in order to avoid skipping RANKS

 

https://msdn.microsoft.com/en-us/library/gg492185.aspx

 

=
RANKX (
    ALLSELECTED ( EnergyMeterReponses[Squad] ),
    AVERAGEX ( RELATEDTABLE ( EnergyMeterReponses ), EnergyMeterReponses[Energy] ),
    ,
    ,
    DENSE
)

 


Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
v-jiascu-msft
Employee
Employee

Hi Sud,

 

Can you share a sample and the expected result please?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-jiascu-msft,

 

  I have updated my post with the screenshots let me know if you need more information.

 

Thanks,

Sud

Hi @Anonymous

 

You need to specify the last parameter of RANKX i.e TIES in order to avoid skipping RANKS

 

https://msdn.microsoft.com/en-us/library/gg492185.aspx

 

=
RANKX (
    ALLSELECTED ( EnergyMeterReponses[Squad] ),
    AVERAGEX ( RELATEDTABLE ( EnergyMeterReponses ), EnergyMeterReponses[Energy] ),
    ,
    ,
    DENSE
)

 


Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

I achieve this by creating a simple table that has 2 columns:

 

  • Selection Name to display
  • ID

 

I create a slicer, as a dropdown, that uses the "Selection Name to Display" column, with single selection on.  To the average user, they are just picking from a list of options.  Doing this, filters that table such that there is only 1 row for context.

 

I create a Dynamic measure with a switch statement.  This is something like

Graph Result = SWITCH(MIN('Selection Table'[ID]),
    2, [Revenue],
    3, [TEC],
    4, [Non-Wage Costs],
    5, [Revenue per FTE],
    6, [EBIT per FTE],
    7, [TEC Per FTE],
    8, [TEC as Percent Revenue],
    9, [FTE],
    10, [Turnover],
    11, [Budget Other Expenses],
    [EBIT])


Since we are using a MIN statement, that allows me to have the first record of my Selection Table to be the default showing if anything goes wrong.

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.