Forum Discussion

Daxmon_23's avatar
Daxmon_23
Frequent Visitor
3 years ago
Solved

From Tableau Fixed function to Power BI DaX

Hi everyone,

I am trying to move my reports from Tableau to Power BI and i have some below FIXED function which should be written in DAX.

Can any one please help to convert Tableau LOD to Power BI DAX ?

IF

[Categories]= 'CANDIES' THEN
{ FIXED

[Unique ID],[Categories]

:
IF

[PRECIO PROMEDIO]<450

THEN 'LESS THAN 500'
ELSEIF

[PRECIO PROMEDIO]>450 AND [PRECIO PROMEDIO] =< 550

THEN '$500'
ELSEIF

[PRECIO PROMEDIO]>550 AND [PRECIO PROMEDIO] =< 650

THEN '$600'
ELSEIF

[PRECIO PROMEDIO]>650 THEN 'MORE THAN  $600'
END

}
END

  • Hi Daxmon_23 ,

     

    Change your formula like below:

    Cump =
    VAR a =
        SWITCH (
            TRUE (),
            [Precio Prom] < 450, "0-$450",
            AND ( [Precio Prom] > 450, [Precio Prom] <= 550 ), "$500",
            AND ( [Precio Prom] > 550, [Precio Prom] <= 650 ), "$600",
            [Precio Prom] >= 600, "More than $600"
        )
    RETURN
        CALCULATE (
            a,
            ALLEXCEPT ( Sales, Sales[UniqueID] ),
            ALLEXCEPT ( Product, Product[Categories] )
        )

    or maybe:

    Cump =
    VAR a =
        SWITCH (
            TRUE (),
            MAX ( DimProduct[Color] ) = "Red", "red",
            AND (
                MAX ( DimProduct[Color] ) = "Black",
                ( MAX ( DimProduct[Color] ) = "Grey" )
            ), "grey",
            "Other color"
        )
    RETURN
        CALCULATE ( a, ALLEXCEPT ( DimDate, DimDate[FiscalYear] ) )

     

    If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


    Best Regards,
    Henry


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

3 Replies

    • Daxmon_23's avatar
      Daxmon_23
      Frequent Visitor

      hi amitchandak , thanks for your help.

      My try after seeing it was as follows but I get errors I can't seem to find why

      Cump =
      CALCULATE(
          SWITCH(TRUE(),
                  [Precio Prom] < 450, "0-$450",
                  AND ([Precio Prom] >450, [Precio Prom] <=550),"$500",
                  AND ([Precio Prom] >550, [Precio Prom] <=650),"$600",
                  [Precio Prom] >= 600, "More than $600",
          ALLEXCEPT(Sales,Sales[UniqueID]),
          ALLEXCEPT(Product,Product[Categories])
      ))
  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi Daxmon_23 ,

     

    Change your formula like below:

    Cump =
    VAR a =
        SWITCH (
            TRUE (),
            [Precio Prom] < 450, "0-$450",
            AND ( [Precio Prom] > 450, [Precio Prom] <= 550 ), "$500",
            AND ( [Precio Prom] > 550, [Precio Prom] <= 650 ), "$600",
            [Precio Prom] >= 600, "More than $600"
        )
    RETURN
        CALCULATE (
            a,
            ALLEXCEPT ( Sales, Sales[UniqueID] ),
            ALLEXCEPT ( Product, Product[Categories] )
        )

    or maybe:

    Cump =
    VAR a =
        SWITCH (
            TRUE (),
            MAX ( DimProduct[Color] ) = "Red", "red",
            AND (
                MAX ( DimProduct[Color] ) = "Black",
                ( MAX ( DimProduct[Color] ) = "Grey" )
            ), "grey",
            "Other color"
        )
    RETURN
        CALCULATE ( a, ALLEXCEPT ( DimDate, DimDate[FiscalYear] ) )

     

    If the problem is still not resolved, please provide detailed error information and test data. Looking forward to your reply.


    Best Regards,
    Henry


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