Forum Discussion

curtismob's avatar
curtismob
Helper IV
3 years ago

MINX Measure Ignoring Slicer Filtering

The minimum of current cost measure below, works for the most part, but the minimum still pulls values from Community[_cCommunity with Number] and/or Options[_cOption Plan/Elev] combinations, that have been excluded via the slicers selections.  Is there a way to rewrite the Cost Min measure to get this to work where the minimum cost uses the filtered data only.

 

Cost MIN =
CALCULATE(
MINX (
SUMMARIZE(
    Options,
    Options[Option],
    Community[_cCommunity with Number],
    Options[_cOption Plan/Elev]),
    'Option Cost'[Cost Current] ),
    ALLEXCEPT ( Options, Options[Option], Community[Division]))
 
Cost Current =
VAR
ActiveCost =
CALCULATE(SUM('Option Cost'[Cost]),
FILTER('Option Cost',
('Option Cost'[Bid/Takeoff] = "B" &&
'Option Cost'[Effective] <= 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Expiration] > 'Option Cost'[_cCurrent Date])
||
('Option Cost'[Bid/Takeoff] = "T" &&
'Option Cost'[Effective] <= 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Expiration] > 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Vendor Assignment Effective] <= 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Vendor Assignment Expiration] > 'Option Cost'[_cCurrent Date]) &&
'Option Cost'[Vendor Number] = 'Option Cost'[_mFirst Takeoff Vendor]
))
VAR
InactiveCostNoVendAssn =
CALCULATE(SUM('Option Cost'[Cost]),
FILTER('Option Cost',
'Option Cost'[Bid/Takeoff] = "T" &&
'Option Cost'[Effective] <= 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Expiration] > 'Option Cost'[_cCurrent Date] &&
'Option Cost'[Vendor Assignment Expiration] < 'Option Cost'[_cCurrent Date]
// && 'Option Cost'[Vendor Number] = 'Option Cost'[_mFirst Takeoff Vendor]
))
VAR
Cost =
IF(ActiveCost <> BLANK(), ActiveCost, InactiveCostNoVendAssn)
RETURN
Cost + 'Option Cost'[_mMin Zero]
 
Thank you in advance,

14 Replies

    • curtismob's avatar
      curtismob
      Helper IV

      parry2k , thank you for the quick response.  Unfortunately, my actual dataset it too large to upload, so hopefully the two examples below will help clarify my issue.   

       

      OptionCommunityPlan/ElevCurrent CostMin CostVariance $Variance %
      OPTION1Community1+/+149901499100%
      OPTION1Community2+/+217302173100%
      OPTION1Community3+/+105001050100%
      OPTION1Community4+/+0000%
      OPTION1Community5+/+100701007100%
      OPTION1Community6+/+100701007100%

       

      Community4 deselected in the Comminty slicer, but the minimum of current cost is still 0, instead of 1007

       

      OptionCommunityPlan/ElevCurrent CostMin CostVariance $Variance %
      OPTION1Community1+/+149901499100%
      OPTION1Community2+/+217302173100%
      OPTION1Community3+/+105001050100%
      OPTION1Community5+/+100701007100%
      OPTION1Community6+/+100701007100%

       

      Thank you again,

      curtismob 

  • curtismob thanks for sharing the sample data but what you are trying to achieve, could you please explain that?

    • curtismob's avatar
      curtismob
      Helper IV

      I am just trying to find the lowest/minimum cost for a given option within the group, where the group are the columns in the SUMMARIZE portion of the MINX measure (see columns below).

       

      Options[Option],
      Community[_cCommunity with Number],
      Options[_cOption Plan/Elev]
    • curtismob's avatar
      curtismob
      Helper IV

      I apologize, I just re-read my earlier post and it was not clear.  I re-worded it below.

       

      With Community4 deselected in the Comminty slicer, The desired minimum cost would be 1007, but it remains 0.

       

      OptionCommunityPlan/ElevCurrent CostMin CostVariance $Variance %
      OPTION1Community1+/+149901499100%
      OPTION1Community2+/+217302173100%
      OPTION1Community3+/+105001050100%
      OPTION1Community5+/+100701007100%
      OPTION1Community6+/+100701007100%
    • curtismob's avatar
      curtismob
      Helper IV

      Thank you for the suggestion, but unfortunately, this does not take into account the grouping requirement.  The suggested measure calculates the minimum cost for all selected options, as opposed to the minimun cost within the group.  The measure below works correctly, until a community is deselected in the community slicer.

       

      Cost MIN =
      CALCULATE(
      MINX (
      SUMMARIZE(
          Options,
          Options[Option],
          Community[_cCommunity with Number],
          Options[_cOption Plan/Elev]),
          'Option Cost'[Cost Current] ),
          ALLEXCEPT ( OptionsOptions[Option]Community[Division]))
  • curtismob not sure what that means. What do you mean by grouping? if you clarify everything in one go, it will help.

    • curtismob's avatar
      curtismob
      Helper IV

      Hopefully this will help to clarify the requirement to find the minimum cost within a group, where the group  in this case is Option.  I have added data examples for 2 options, as opposed to only 1.

       

      Data prior to any slicer filtering.  This data is correct, before removing COMMUNITY4.  

      OptionCommunityPlan/ElevCurrent CostMin Option Cost
      OPTION1COMMUNITY11/A10070
      OPTION1COMMUNITY21/A21730
      OPTION1COMMUNITY31/A10070
      OPTION1COMMUNITY41/A00
      OPTION1COMMUNITY51/A14990
      OPTION1COMMUNITY61/A10500
           
      OPTION2COMMUNITY11/A15710
      OPTION2COMMUNITY31/A15710
      OPTION2COMMUNITY41/A00
      OPTION2COMMUNITY61/A16270

       

      Data after slicer filtering removing COMMUNITY4, 0 remains the minimum, even though COMMUNITY4 with the minimum of 0 for both OPTION1 and OPTION2, have been removed using slicer selections.  There is no longer a Current Cost of 0.

      OptionCommunity NumberPlan/ElevCurrent CostMin Option Cost
      OPTION1COMMUNITY11/A10070
      OPTION1COMMUNITY21/A21730
      OPTION1COMMUNITY31/A10070
      OPTION1COMMUNITY51/A14990
      OPTION1COMMUNITY61/A10500
           
      OPTION2COMMUNITY11/A15710
      OPTION2COMMUNITY31/A15710
      OPTION2COMMUNITY61/A16270

       

      These are the desired results, after the slicer filtering removing COMMUNITY4.

      OptionCommunity NumberPlan/ElevCurrent CostMin Option Cost
      OPTION1COMMUNITY11/A10071007
      OPTION1COMMUNITY21/A21731007
      OPTION1COMMUNITY31/A10071007
      OPTION1COMMUNITY51/A14991007
      OPTION1COMMUNITY61/A10501007
           
      OPTION2COMMUNITY11/A15711571
      OPTION2COMMUNITY31/A15711571
      OPTION2COMMUNITY61/A16271571

       

      Thanks again,

      curtismob 

  • Hello, I am still trying to resolve this issue.  I have used previous suggestions in the post, which have gotten me closer, but I still need help getting the MINX to work with slicer selections.  Below is the link to the desktop file for the data and report examples below.

     

    https://drive.google.com/file/d/10PEccWeAmykc42N9yB5o_OL30ZvkmL4q/view?usp=drive_link

     

    Here are the Curr Cost and Min Curr Cost measures:

     

    _mOption Cost Current Date =

    VAR

    ActiveCost =

    CALCULATE(SUM(OptionCost[Cost]),

    FILTER('OptionCost',

    ('OptionCost'[Cost Type] = "B" &&

    'OptionCost'[Effective] <= 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Expiration] > 'OptionCost'[_cCurrent Date])

    ||

    ('OptionCost'[Cost Type] = "T" &&

    'OptionCost'[Effective] <= 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Expiration] > 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Vendor Assignment Effective] <= 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Vendor Assignment Expiration] > 'OptionCost'[_cCurrent Date])

    ))

     

    VAR

    InactiveCostNoVendAssn =

    CALCULATE(SUM('OptionCost'[Cost]),

    FILTER('OptionCost',

    'OptionCost'[Cost Type] = "T" &&

    'OptionCost'[Effective] <= 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Expiration] > 'OptionCost'[_cCurrent Date] &&

    'OptionCost'[Vendor Assignment Expiration] < 'OptionCost'[_cCurrent Date]

    ))

     

    VAR

    Cost =

    IF(ActiveCost <> BLANK(), ActiveCost, InactiveCostNoVendAssn)

     

    RETURN

    Cost

     

    _mOption Cost Current Date MIN =

    CALCULATE(

    MINX (

    SUMMARIZE(

        Option,

        Option[Option],

        Community[Community],

        Option[Plan/Elev]),

        OptionCost[_mOption Cost Current Date] ),

        ALLEXCEPT ( Option, Option[Option], Community[Division]))

     

    On this screen shot, the data is correct.

     

    On the following screenshot, the Min Curr Cost for the Option is not recalculated after deselecting certain communities.

     

     

    Thank you in advance,

    curtismob 

     

  • curtismob try this:

     

    MINX ( ALLSELECTED ( Community[Community] ), [_mOption Cost Current Date] )
    • curtismob's avatar
      curtismob
      Helper IV

      parry2k, thanks again for your response.  It is almost there.  I wanted to validate it still worked for all communities, and you will notice the minimum for OPTION3 is no longer correct using the new measure.  The old measure works for all communities, but not when slicer selections are made to remove communities.  The new measure works when slicer selections are made to remove communities, but not when all communities are inclduded.