Forum Discussion

TejasShah's avatar
TejasShah
Icon for Helper I rankHelper I
2 years ago
Solved

Compare 2 visual tables and add condition

It'll be really helpful if someone can guide me since I have this case since a long time and couldn't get any related online solution for the same. I have 2 databases from where I have annual data o...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi TejasShah 

     

    Not sure how your source data looks like, so I create a simple demo to show a general and simple practice. 

     

    Assume that your data table is like below. This is a friendly format for Power BI and will make follow-up calculations easier. If your tables are not in this format, you can use Power Query to transform them into this format in advance. 

     

    Add two dimension tables for Cell No and Types. Then link them to Cell No column and Type column in both Annual and Daily tables. This follows the star schema model idea. 

     

    Then create matrix visuals instead table visuals. Use Dimension tables' Cell No and Type column on row and column in both matrices. Create measures to calculate the Avgs for each. 

     

    Then create the following measure for color formatting. In this measure, compare the daily Avg measure with Annual Avg measure. 

    Color = 
    VAR _DailyAvg = [Daily Avg]
    VAR _AnnualAvg = [Annual Avg]
    RETURN
    IF(_DailyAvg>=_AnnualAvg-10 && _DailyAvg<=_AnnualAvg+10, "Green", "Red")

    Hope this would be helpful. If you have any question, feel free to ask and @ me. 

     

    Best Regards,
    Jing
    If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!