Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
lisago1978
Helper III
Helper III

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 7
v-juanli-msft
Community Support
Community Support

Hi @lisago1978 

I'm not very clear about your criteria.

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

1.png

 

Could you show me your expected result?

Or clear me more?

 

Best Regards
Maggie

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

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"

Thank you for the response. The code didn't exactly work. It said I was missing a comma but couldn't put it in. The other problem is that the Totals table will need to have more than 1 row since  I have multiple indicators and multiple totals in the same table. So I would need code that matches a specific text indicator for example "low birth weight" and a datayear "2010" and then finds the LCI and UCI in that row to compare to the data table with matching text and year indicator rows. I am happy to send the 2 tables I am refering to if this helps.

 

Thanks

Lisa

I knew your real data was different! 

Send the tables and i'll have a look.

 

 

For the initial "missing comma" issue, there's either a syntax error at your side OR the column headings and types are wrong in the 2 tables.  The code works when the tables are set up correctly.

Thanks, I don't think I can send an attachment with my tables using this community forum, it you know of a way let me know. I can't share my dashboard with you because I am limited only to those in my organization in terms of how our permissions are set up. If you have an email address I can email the tables to you.

Thank you!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors