Modify the function to ignore the filter in slicer on 'CustomerSKUShareMonth'[Year] ROI…
- User
Modify the function to ignore the filter in slicer on 'Customer_SKU_Share_Month'[Year]
ROI vs LY = VAR ROI_CY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER('Customer_SKU_Share_Month', 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && 'Customer_SKU_Share_Month'[Year] = MAX('Customer_SKU_Share_Month'[Year]) && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) VAR ROI_LY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER('Customer_SKU_Share_Month', 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && 'Customer_SKU_Share_Month'[Year] = MAX('Customer_SKU_Share_Month'[Year])-1 && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) RETURN IF(ISNUMBER(ROI_LY),(ROI_CY-ROI_LY)*100,"")
- Assistant
To modify the function to ignore the filter on 'Customer_SKU_Share_Month'[Year], you can use the ALL function to remove the filter for that specific column. Here's the modified function:
ROI vs LY = VAR ROI_CY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER(ALL('Customer_SKU_Share_Month'), 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) VAR ROI_LY = CALCULATE( DIVIDE(SUM('Customer_SKU_Share_Month'[SUM_GP])-SUM('Customer_SKU_Share_Month'[SUM_Log]),SUM('Customer_SKU_Share_Month'[SUM_Disc])), FILTER(ALL('Customer_SKU_Share_Month'), 'Customer_SKU_Share_Month'[SUM_TotVol] <> 0 && 'Customer_SKU_Share_Month'[SUM_PromoVol] <> 0 && NOT(ISERROR('Customer_SKU_Share_Month'[ROI(share, add%)_log2])) )) RETURN IF(ISNUMBER(ROI_LY),(ROI_CY-ROI_LY)*100,"")
- User
How to determine the measure to sum the values of A for TOP N in slicer for B?
- Assistant
To determine a measure that sums the values of measure A for the top N items selected in a slicer for measure B, you can follow these steps:
-
Create a measure that calculates the sum of measure A. Let's call this measure "Sum_A".
Sum_A = SUM('Table'[Measure_A])
-
Create a measure that calculates the rank of measure B for each item.
Rank_B = RANKX(ALL('Table'[Item]), [Measure_B], , DESC, Dense)
This measure assigns a rank to each item based on the value of measure B in descending order. The "ALL('Table'[Item])" removes any existing filters on the 'Table'[Item] column.
-
Create a measure that calculates the sum of measure A only for the top N items selected in a slicer for measure B.
Sum_A_Top_N = IF( ISFILTERED('Table'[Item]), CALCULATE( [Sum_A], TOPN( N, ALL('Table'[Item]), [Rank_B] ) ), [Sum_A] )
This measure checks if there is a filter on the 'Table'[Item] column. If there is a filter, it uses the TOPN function to get the top N items based on the rank of measure B. Otherwise, it simply returns the sum of measure A.
-
- User
Help to fix that Promo Vol, TOP N = IF( ISFILTERED(Products[Product name M3]), CALCULATE( SUM('Share16вед'[Отгрузка по акции, л.]), TOPN(SELECTEDVALUE('Rank'[Value]), ALL(Products[Product name M3]) ) ))
- Assistant
To fix the measure 'Promo Vol, TOP N', you need to add an additional argument in the TOPN function to specify the column to be used for ranking. Here's the modified measure:
Promo Vol, TOP N = IF( ISFILTERED(Products[Product name M3]), CALCULATE( SUM('Share16вед'[Отгрузка по акции, л.]), TOPN( SELECTEDVALUE('Rank'[Value]), ALL(Products[Product name M3]), [Measure_B] // Replace [Measure_B] with the column to be used for ranking ) ) )
Make sure to replace 'Products[Product name M3]' with the actual column name on which the slicer is based and '[Measure_B]' with the column to be used for ranking.