Forum Discussion

lisago1978's avatar
lisago1978
Helper III
7 years ago

Help with conditional columns referencing total amounts

I need some insight into how to create the following in either power query or power BI

 

I have a series of zipcodes that I am referencing the individual zip code % yes confidence interval (margin or effor) to the total % yes confidence interval. I am trying to replicate the 'cond' column in either powery query or power BI.

 

 I need to do this many times so rather than the cell location- the name 'Total'[LCI] would be better to reference.

 

Here is my excel code

=IF(AND(F6<$F$17,G6<$G$17),"LOWER",IF(AND(F6>$F$17,G6>$G$17),"HIGHER","SAME"))

 

Here is the data

 

ZipcodeCountDenominator% yesLCIUCIcondtier
900012813892.01.32.9LOWER2.0
9000281674.82.19.4SAME3.0
90003368214.43.16.1SAME3.0
90004296454.53.06.5SAME3.0
9000571464.81.99.9SAME3.0
90006236203.72.45.6SAME2.0
9000751872.70.96.2SAME2.0
90008345596.14.28.5HIGHER4.0
90009102344.32.07.9SAME3.0
90010287893.52.45.1SAME2.0
900114612613.62.74.9SAME2.0
Total858218463.93.74.2SAME4.0

 

7 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Community Support

    Hi lisago1978 

    I'm not very clear about your criteria.

    As tested in excel, "UCI" is "F" column, "cond" is "G" column. 

     

    Could you show me your expected result?

    Or clear me more?

     

    Best Regards
    Maggie

    • lisago1978's avatar
      lisago1978
      Helper III

      Thanks for responding and I am sorry I realized the forgot to include the row and column specifications. 

       

      Here it is

       

      1BCDEFGHI
      2ZipcodeCountDenominator% yesLCIUCIcondtier
      3900012813892.01.32.9LOWER2.0
      49000281674.82.19.4SAME3.0
      590003368214.43.16.1SAME3.0
      690004296454.53.06.5SAME3.0
      79000571464.81.99.9SAME3.0
      890006236203.72.45.6SAME2.0
      99000751872.70.96.2SAME2.0
      1090008345596.14.28.5HIGHER4.0
      1190009102344.32.07.9SAME3.0
      1290010287893.52.45.1SAME2.0
      13900114612613.62.74.9SAME2.0
      14Total858218463.93.74.2SAME4.0

       

      And the formula is =IF(AND(F3<$F$14,G3<$G$14),"LOWER",IF(AND(F3>$F$14,G3>$G$14),"HIGHER","SAME"))

       

      So I am doing a logical formula for the lower and upper CIs. Wherein if the value is lower than both total LCI and UCI it is lower. If the value is higher than both total LCI and UCI than it is higher otherwise it is the same. Let me know what else you need from me.

       

      Thanks

      Lisa

      • HotChilli's avatar
        HotChilli
        Community Champion

        In Power Query, Duplicate the table and 'Keep Rows' -> Bottom 1.

        This will give you a 1 row table with the Totals line in it.  Re-name this table Totals.

        In the original table, add a column with this code

        if [LCI] < List.First(Totals[LCI]) and [UCI] < List.First(Totals[UCI]) then "LOWER" else 
        if [LCI] > List.First(Totals[LCI]) and [UCI] > List.First(Totals[UCI]) then "HIGHER" else "SAME"