Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
5 years ago
Solved

formula DAX

Good morning, I would like you to provide me with a formula to obtain the value to return, that is to say without in the column percentage continent the value% returns me the value before the % of the contario that returns me white.

percentageamount to be returned
30dwhite
15dwhite
5dwhite
15dwhite
15d2%2%
10d2%2%

Thank you.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Syndicate_Admin ,

    You can create a calculated column as below:

    amount to be returned = 
    VAR _len =
        LEN ( 'Table'[percentage] )
    VAR _pplace =
        IFERROR ( SEARCH ( "%", 'Table'[percentage], 1, 0 ), 0 )
    VAR _dplace =
        IFERROR ( SEARCH ( "d", 'Table'[percentage], 1, 0 ), 0 )
    RETURN
        IF (
            _pplace > 0,
            MID ( 'Table'[percentage], _dplace + 1, _pplace - _dplace ),
            "white"
        )

    Best Regards

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Syndicate_Admin ,

    You can create a calculated column as below:

    amount to be returned = 
    VAR _len =
        LEN ( 'Table'[percentage] )
    VAR _pplace =
        IFERROR ( SEARCH ( "%", 'Table'[percentage], 1, 0 ), 0 )
    VAR _dplace =
        IFERROR ( SEARCH ( "d", 'Table'[percentage], 1, 0 ), 0 )
    RETURN
        IF (
            _pplace > 0,
            MID ( 'Table'[percentage], _dplace + 1, _pplace - _dplace ),
            "white"
        )

    Best Regards