Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Convert Tableau expression into power bi DAX

Hi Team, Need some help to convert tableau expression to power bi "ATTR([TSR Created Date _ Today N])", i tried with selectedvalue function but it's not working so can anyone help me how to convert from Tableau to Power bi.

  • Anonymous These usually go better if you provide sample data and expected result but in this case, I believe the equivalent DAX is:

     

    Measure = 
      VAR __Table = SUMMARIZE( 'Table', [TSR Created Date _ Today N] )
      VAR __Result = IF( COUNTROWS( __Table ) > 1, "*", MAXX( __Table, [TSR Created Date _ Today N] ) )
    RETURN
      __Result

     

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous These usually go better if you provide sample data and expected result but in this case, I believe the equivalent DAX is:

     

    Measure = 
      VAR __Table = SUMMARIZE( 'Table', [TSR Created Date _ Today N] )
      VAR __Result = IF( COUNTROWS( __Table ) > 1, "*", MAXX( __Table, [TSR Created Date _ Today N] ) )
    RETURN
      __Result

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    See the below data:

    When I use attr:

    Final I get:

     

    Import data to Power BI:

    You can try this DAX code: 

    ATTR = 
    VAR MAXVALUE =
        CALCULATE (
            MAX ( 'Table'[State] ),
            FILTER ( ALL ( 'Table' ), 'Table'[City] = MAX ( 'Table'[City] ) )
        )
    VAR MINVALUE =
        CALCULATE (
            MIN ( 'Table'[State] ),
            FILTER ( ALL ( 'Table' ), 'Table'[City] = MAX ( 'Table'[City] ) )
        )
    RETURN
        IF ( MAXVALUE = MINVALUE, MAX ( 'Table'[State] ), "*" )

    Finally you will get what you want.

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.