"rankx"
20 TopicsRanking with RANKX, FILTER, ALL & CALCULATE not working in Direct Query mode
Has anyone had issues ranking using Direct Query vs import modes? I am using the following measure which works when the table is imported but not in direct query mode: Rank Test = RANKX( FILTER( ALL( accounts[last_program_size], accounts[program_size] ), accounts[last_program_size] = MAX(accounts[last_program_size]) ), CALCULATE( sum(accounts[count_flag]) ) ) A number of the functions used have this remark in the official documentation but I am not using it in a calculated column and do not have RLS configured. This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules. Thanks.Solved2.4KViews0likes11CommentsNeed help with showing data for Sellers ranked between 1 to 10 (dynamic user selection)
Hello All, I need to show the Rank of Sellers by their count in selected year (Count YTD). Give the ability to users to filter sellers for rank 1 to 10 or 10-20 (whatever they desire). This works fine using RANK measure and then creating a numeric range parameter for slicer selection. The problem comes, when I try to show the data for only these sellers which has ranks selected by the user in another table with Price Range and Count YTD. I have shared the measures and expected output. Kindly help. Measure1 Rank Sellers RANKX(ALL(Sample_Data[Seller]), [Count YTD],, DESC) Measure2 (to filter the sellers based on user selection) Selected Rank Sellers = VAR _MaxSel = MAX('Top N Sellers'[Top N Sellers]) VAR _MinSel = Min('Top N Sellers'[Top N Sellers]) RETURN INT(AND ([Rank Sellers] <= _MaxSel , [Rank Sellers] >= _MinSel )) If user selectes 1 to 10 in slicer, I get the following output- Seller Count YTD RVJNISH 79193 MINAR 56796 GROUPS 25760 GVM 20716 MHOMES 13247 MORRISON 13167 DHOMES 12321 KHOME 11666 LHOMES 10279 Rajeev 9651 Grand Total 252796 The requirement is to show - Closings Price Range Count YTD $250k-$499k 1,47,721 $100k-$249k 60,660 $500k-$999k 31,028 <$100k 10,952 $1M or More 2,435Solved1.5KViews0likes11CommentsRank basing on measure with parameter & Rank percentile
Hi Everyone, 1) I have created following measure in DAX: Model score weighted FA Table = [Productivity FA table Value] / 100 * AVERAGE(act_source[team_prod_model_score]) + (100 - [Productivity FA table Value])/100 * AVERAGE(act_source[fa_prod_model_score]) Where [Productivity FA table Value] is defined by What-If parameter as following: Productivity FA table = GENERATESERIES(0, 100, 50) Now I am strugling to prepare rank field using above measure. Basically I am trying to find equivalent of Rank_Unique() function in Tableau, which look like as follows: 2) Similar question related to ranking. I have field in my data called [surv_model_score]. I want to apply almost exactly same formula of Rank_Unique as above. Additionaly, on the output, I want to apply equivalent of Rank_Percentile() function as follows: Is there any way to get equivalent of rank_percentile in my case? Thanks and Merry Christmas !527Views0likes1CommentHelp with Running Sum Measure Using Virtual Tables and Rank in DAX
Hi everyone, I'm trying to create a running sum measure in DAX that changes dynamically based on the applied filters. The running sum should accumulate values according to the rank of each row. I've already created separate tables, and they work as expected. However, when I attempt to implement this using a measure with virtual tables, it doesn't produce the desired result. Here's the code I'm working with. Each part seems to work independently (e.g., ranking and filtering), but as a combined measure, it fails to return the correct running sum per rank. Running_sum_measure = VAR tbl_1 = ADDCOLUMNS( FILTER(ALL(sales_table[CodigoArticulo]),[CQ1]>0) ,"porc" ,[PorcentajeParticipacionCQ1] ) VAR tbl_1_sorted = ADDCOLUMNS( tbl_1, "Rank", RANKX( tbl_1, [porc] + RAND() * 0.0001, // Adding a slightly larger random component to ensure uniqueness , DESC, Dense ) ) VAR table_rank = ADDCOLUMNS( tbl_1_sorted, // Columna "RowNumber" para asignar un número de fila único a cada registro "RowNumber", RANKX( ALL(tbl_1_sorted), // Considera todos los registros de la tabla sin filtros [Rank] + RANKX( ALL(tbl_1_sorted), CALCULATE( MAXX(tbl_1_sorted, tbl_1_sorted[CodigoArticulo]) // Valor máximo de CodigoArticulo para el desempate ), , ASC, Dense // Usa Dense para clasificaciones consecutivas ) / COUNTROWS(ALL(tbl_1_sorted)), // Ajuste para evitar empates basado en el total de filas , ASC, Dense // Usa clasificación ascendente y consecutiva para "RowNumber" ) ) VAR final_ = ADDCOLUMNS( SUMMARIZE( table_rank, table_rank[CodigoArticulo], table_rank[RowNumber], "porc", SUM(table_rank[porc]) ), "RunningSum", VAR CurrentRank = [RowNumber] RETURN CALCULATE( SUM(table_rank[porc]), FILTER( ALL(table_rank), table_rank[RowNumber] <= CurrentRank && table_rank[CodigoArticulo] = [CodigoArticulo] ) ) ) VAR running_current = SUMX(final_,[RunningSum]) RETURN running_current the initital table will look something like this CodigoArticulo porc abc234hj21 0.001269819292983 bc234hj21 0.023401928347459 bc234hj223 0.032123394040404 bc234hj24gn 0.011001110932900 If anyone has experience with handling ranks with tie-breakers in a measure like this, I’d appreciate any advice on how to make this running sum work dynamically with filters and rankings. Thank you in advance for any help you can provide!Solved1KViews1like1CommentDynamic Top N Parameter doesn't work when adding a LEGEND to a Stacked Bar Chart
Link to pbix: Dynamic TopN with Legend not working.pbix In my sample, I have a horizontal stacked bar chart (Sales by City) that interacts correctly with the dynamic Top N parameter: I used the following rank measure: Rank_City = RANKX( ALLSELECTED('Dim_City'[City]), [Sales Amount], , DESC, DENSE ) And a measure applied to the chart as a filter to activate the dynamic Top N: TopNCity = IF([Rank_City] <= 'TopN'[TopN Value], 1, 0) All is well until adding a sub-category as a legend breaks the dynamic top N: How do I make sure the chart still displays the correct number of cities even with a sub-category applied as a legend? I have attached a link to the sample pbix. Thank you!780Views0likes2CommentsConsistent Ranking Measure Ignoring Page Slicers
I am trying to create a ranking measure in Power BI based on a specific variable while ensuring that the ranking remains consistent regardless of any slicers applied on the page. But the ranking changes when the slicer is applied. The ranking should remain the same irrespective of any slicers applied on the page (specifically, slicers for Category). I have tried ALL and ALLSELECTED but the rankings change when I applied the slicers. Here is the measure I used: rank = RANKX(ALL(Table),CALCULATE(SUM(Table[Income]),REMOVEFILTERS(Table[Category])),,DESC,Dense) When I apply the slicer, the ranking position decreases by one spot with this measure. How can I change this for it to work?1.3KViews0likes4CommentsTop 3 flags being removed
Hi, I'm needing help with a measure to get the top 3 support needs being removed on a month to month basis. I have a transactional table, "CUSTOMER_FLAGS" with customers, "CUSTOMER_FLAGS"[Customer], that have flags against them for support needs "CUSTOMER_FLAGS"[FLAG_ID]. Customers can have one or more flags against them. I have a date table "DATE"[Date], and relevant date columns in my table connected to this are "CUSTOMER_FLAGS"[ACTIVE_AT], "CUSTOMER_FLAGS"[EXPIRES_AT]. The "DATE"[Date] column is connected to "CUSTOMER_FLAGS"[ACTIVE_AT]. I also have "FLAG_REFERENCE" table with "FLAG_REFERENCE"[FLAG_NAME] to define what the flags are, [FLAG_ID] '103' = FLAG_NAME 'I need help with reading' etc and is connected via "FLAG_REFERENCE"[FLAG_ID] to "CUSTOMER_FLAGS"[FLAG_ID]. I need to see on a month to month basis, the top 3 support needs that are being removed; this is to see which support needs customers are needing less over time. I have struggled with this as it's both needing to get the support needs that are being removed over time, not the number of customers, but also with the added necessity to see it as the top 3 being removed. Many thanks in advance, Data-Papa.424Views0likes1CommentURGENT!! Convert Measure to Calculated Column
Hello Power BI community! Need some urgent help in converting the following measure to a calculated column. The min purpose is that I can use this new column as a legend for my pie chart. Ranking SingleSelect = RANKX(ALLSELECTED('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense) @MFelix , @amitchandak , @Ashish_MathurSolved1.6KViews2likes6CommentsURGENT!! Ranking measure not working.
Hello Power BI community!Preview Can you help me with the below ranking code? This code is giving me the same ranking for different % of search order columns: SortingOrderSearchOrder_SingleSelect = VAR SelectedProducts = {"Search Order (First)", "Brand First", "Category First", "Flavour Variant First", "Format First", "Not Answered", "Nutritional Content First", "Others First", "Pack Size First", "Pack Type First", "Packaging Design First", "Price First", "Product Origin First", "Promotion First", "Returnable Packaging First", "Temperature First", "Try New First", "Unit Type First" } RETURN IF( max('df_Search Order (First)'[Search Order (First)]) IN SelectedProducts, RANKX( FILTER( ALL('df_Search Order (First)'[Search Order (First)]), 'df_Search Order (First)'[Search Order (First)] IN SelectedProducts ), [Ranking SingleSelect], , ASC ), 0 ) below is a screenshot of the measure - Following are the reference measures used: Category_Occasion_SingleSelect% = [DistinctCount_Category_Occasions_SingleSelect]/ [TotalSum_Category_Occasion_SingleSelect] Ranking SingleSelect = RANKX(ALL('df_Search Order (First)'[Search Order (First)]), [Category_Occasion_SingleSelect%], , DESC, Dense) MFelix , amitchandak , Ashish_MathurSolved1.3KViews0likes8CommentsRankx with ties
Hello All, I have a ranking issue I can't solve. I have the below table: 1 same group can have multiple dealers. My ranking formula is the following: ranking test = IF(NOT (ISBLANK([Score in %])),CALCULATE(RANKX(ALLSELECTED(Lookup__Dealer), [Score in %], , DESC)), BLANK()) This works well. However, when I add the Region column (coming from a separate dim table), it gives me ties: Suddenly, the dealer who was number 1 became number 2 and the number 2 and 3 both became number 3. Therefore, if in my slicer I select bottom 1, it will show me blank value. I need the bottom 1 to remain 1 when I add the Region column like as below: N Group Dealer Full Name Ranking test score in % Region 125 .......7 3 71,11 FR 573 .......6 2 62,22 NL 573 ........2 1 49,44 NL And If I select the Region NL in a slicer, I need my ranking to adapt iself as below: N Group Dealer Full Name Ranking test score in % Region 573 .......6 2 62,22 NL 573 ........2 1 49,44 NL How could I achive this ? Thanks743Views0likes1Comment