Search code examples
powerbidax

First Non Value in a filtered table


_Hi, I struggle to return the first non blank value of my "BDD Index" Table filtered with 'BDD Index'[Ordre TimeLine] = [Mesure 2 MAX ordrerLine].

I Don't understand why the following code returns an empty table, whereas when I replace [Mesure 2 MAX orderLine] by a number & SELECTEDVALUE('BDD Index'[Bat]) by "IGH", it works ? :

FILTER(
            'BDD Index',
            'BDD Index'[Ordre TimeLine] = [Mesure 2 MAX orderLine] && 'BDD Index'[Bat] = SELECTEDVALUE('BDD Index'[Bat])
        ) 

And then my DAX formula won't work :

Mesure FNBV = 
    FIRSTNONBLANKVALUE(
        'BDD Index'[Date & Heure],
        FILTER(
            'BDD Index',
            'BDD Index'[Ordre TimeLine] = [Mesure 2 MAX orderLine] && 'BDD Index'[Bat] = SELECTEDVALUE('BDD Index'[Bat])
        )
    )

Besides, When I calculate the following measure with an IF evaluation, it breaks my filter context and i can't understand why, even when I add a KEEPFILTER context :

Mesure TEST_ =  IF(
    HASONEVALUE('BDD Index'[Bat]) && SELECTEDVALUE('BDD Index'[Ordre TimeLine]) = [Mesure 2 MAX orderLine],
    1,
    0 )

Here is the link of my file

Thanks in advance !

Image of filter context broken enter image description here

instead of (without IF measure)

enter image description here


Solution

  • Change your Mesure 2 MAX orderLine measure to:

    Mesure 2 MAX orderLine = 
      CALCULATE(
        MAX('BDD Index'[Ordre TimeLine]),
        ALLSELECTED('BDD Index')
      )
    

    And update Mesure FNBV to:

    Mesure FNBV = 
      var maxOrder = [Mesure 2 MAX orderLine]
      return CALCULATE(
        FIRSTNONBLANK('BDD Index'[Date & Heure], 1),
        'BDD Index'[Ordre TimeLine] = maxOrder
      )
    

    See if that is what you are after. If it is then I'll follow-up with an explanation or answer any questions. It wasn't clear what you were intending to do.