Forum Discussion

bhaskarpbi999's avatar
1 year ago
Solved

If statement with measure condition not showing correct values in Power BI Desktop

Hi,

 

I have 3 columns  customer name, Rev last year and Rev Current Year in table visualization 

 

Customer name is from Dimension table and Rev is from Fact table.

 

 

I have created a flag custom column with below formula.

Flag = IF(([Rev CY]>[Rev LY]),1,0)
 Even though when Rev CY is greater than Rev LY it is showing all 0 values instead of 1.
 
Could you please assist with a work around for above scenario.
Thanks in Advance.
 
 
Regards,
Bhaskar
 

 

 

 

 

  • bhaskarpbi999 - Calculated Columns are not computed dynamically in visualisations so you should transform this to a measure with:

     

    IF(SUM(FACT_TABLE[Rev CY])>SUM(FACT_TABLE[Rev LY]),1,0)

     

    If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

  • Hi bhaskarpbi999 , Hope you are doing good,

    Try replacing your calculated column with a DAX measure:


    Flag Measure =
    IF(
    [Rev CY] > [Rev LY],
    1,
    0
    )

    Measures are evaluated at the level of the visualization, ensuring proper comparisons.


    If this post helps to answer your question, please consider accepting it as a solution so others can find it more quickly when they face a similar challenge.


    Proud to be a Microsoft Fabric community super user


    Let's Connect on LinkedIn


    Subscribe to my YouTube channel for Microsoft Fabric and Power BI updates.

5 Replies

  • bhaskarpbi999 - Calculated Columns are not computed dynamically in visualisations so you should transform this to a measure with:

     

    IF(SUM(FACT_TABLE[Rev CY])>SUM(FACT_TABLE[Rev LY]),1,0)

     

    If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!

    • bhaskarpbi999's avatar
      bhaskarpbi999
      Icon for Helper V rankHelper V

      Hi Mark,

      Thanks for your extreme support

       

      Regards,

      Bhaskar

      • mark_endicott's avatar
        mark_endicott
        Icon for Super User rankSuper User

        bhaskarpbi999 - Why did you not accept mine as the solution? it was submitted before the other and is exactly the same.

         

        I just used the full syntax. 

  • Hi bhaskarpbi999 , Hope you are doing good,

    Try replacing your calculated column with a DAX measure:


    Flag Measure =
    IF(
    [Rev CY] > [Rev LY],
    1,
    0
    )

    Measures are evaluated at the level of the visualization, ensuring proper comparisons.


    If this post helps to answer your question, please consider accepting it as a solution so others can find it more quickly when they face a similar challenge.


    Proud to be a Microsoft Fabric community super user


    Let's Connect on LinkedIn


    Subscribe to my YouTube channel for Microsoft Fabric and Power BI updates.

    • bhaskarpbi999's avatar
      bhaskarpbi999
      Icon for Helper V rankHelper V

      Hi Anmol,

      Thanks and Kudos to your support.

      Aceepting it as a solution.

      Regards,

      Bhaskar