Forum Discussion

SA800029's avatar
SA800029
New Member
7 years ago

Slicer parameter in DAX

Hi,

 

I'm trying to add a calculated column to a table with a simple formula based on a parameter and a slicer.

 

My parameter is a simple interger ranging from 70000 to 70999, it represents aircraft production rank.
The table has 3 columns : the key, Minimum and Maximum, which refers to the first and last aircraft where the key is effective.

 

What I want to do : I want to be able to select an aircraft (using my parameter as a slicer) then see if the selected Aircraft is in the range Minimum-Maximum, for each rows, by adding an "X" if TRUE and nothig otherwise. The end goal being, once the effective rows are tagged, I'll use this column to apply a page wide filter to keep only the effective keys for the selected aricraft. 

 

I've read several post about using SELECTEDVALUE, my problem is that DAX doesn't seem to compute the value selected so the logical operations fail to determine whether it's True or not.

Here is my formula :

Status = 
VAR
    AC=SELECTEDVALUE('Table Avions'[Table Avions])
RETURN
    IF(MSN_Effectivity[Minimum]<=AC && MSN_Effectivity[Maximum]>=AC;"X";"")

 

The thing that is boggling me is that I've been able to correctly identify the rows with a Measure, that count the keys where the aforementionned criterions are met, but I cannot use the measure to filter the table : 

Count Selected MSN = 
VAR
    MSN=SELECTEDVALUE('Table Avions'[Table Avions])
RETURN

CALCULATE(
    COUNT(MSN_Effectivity[psbEffectivity]);
        FILTER(ALL(MSN_Effectivity[Minimum]);MIN(MSN_Effectivity[Minimum])<=MSN);
        FILTER(ALL(MSN_Effectivity[Maximum]);MAX(MSN_Effectivity[Maximum])>=MSN)
)

Thank you for your help,

 

 

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Not entirely sure I understand this, but if you are trying to use a dynamic measure in a calculated column you are not going to have success. Calculated columns are calculated at the time of data load so selecting a measure in a slicer is not going to have any impact on your calculated column.

    • SA800029's avatar
      SA800029
      New Member

      Hello

      Does this example help ?

      What I want to acheive is just adding an "X" in the rows where 70024 is between Minimum (70016) and Maximum (70034 in the example).
      The number "3" comes from the Measure I've been trying to use as an alternative to identify the rows.
      It works, since I only have a number when the equation is True, but I cannot use it to filter the table since it's a measure.

      That's why I though of a calculated column that I could use latter as a filter.


      Does that make more sens ?

       

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        I don't know why you can't use a measure to filter a table visual, I can. So, if you create a Measure like:

         

        Status = IF(MAX([My Parameter]) >= MAX([Minimum]) && MAX([My Parameter])  <= MAX([Maximum]),"X",BLANK())

        Then just put that into your table visual and filter the measure where Status is X