Forum Discussion

LucaixBolha's avatar
LucaixBolha
Icon for Resolver I rankResolver I
4 years ago
Solved

Text calculated column filtered by value condition (power bi)

Hey guys can someone help me out with this please:

I have several Stock IDs from enterprises, being that an enterprise could have just a single value for its Stock ID, as well as various, having always a base of 4 initial letters (for example the enterprise with the Stock ID "AHEB" has AHEB3, AHEB5 and AHEB6).

My goal is to create a calculated column that already filters these IDs by negotiability (only the most negotiated ID for each enterprise should remain in this column). I'm sending a pbix example of the problem: https://file.io/Rg3izoPcapgW

Creating a new column with just the 4 initial letters as I did in the following example would be perfect for my other purposes if it showed also the rest of the ID (numbers/letters)

  • LucaixBolha's avatar
    LucaixBolha
    4 years ago

    Ahh I got it grantsamborn! But the solution came from another way: I created these three formulas, and filtered my slicer with a Top N visual level filter, adding the variable "FILTERSTOCK" to it, so that it would filter only the Stock Codes that correspond to "TRUE". Here are the formulas, followed by the link with the file:

    1) Last negotiated value column =

    VAR RESULT =
    CALCULATE(
    LASTNONBLANKVALUE('Database'[Date],max('Database'[negotiated value]))
    )
    RETURN RESULT

    2) MaxValuePerStock =
    VAR CurrentStock = max('Stock Codes'[Stock without numbers/letters])
    VAR RESULT =
    CALCULATE(
    [last negotiated value column],
    FILTER(ALL('Stock Codes'), 'Stock Codes'[Stock without numbers/letters] = CurrentStock)
    )
    RETURN RESULT

    3) FILTERSTOCK = if([last negotiated value column]=[MaxValuePerStock],
    TRUE(),
    BLANK())

    File: https://we.tl/t-ADYymPKNDs

    Thank you very much!!! 🙏😊

14 Replies