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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Divide 2 Columns with condition

Hey, 

I would like to divide on column by another (but only by specific value).  So I have a table with oil/gas prices for all Europe in EUR (column weekly price per l) on specific dates of time. I would like calculate prices for all countries in PLN only. 

So let's say Bulgaria has price for Euro-Super 96 for 1,7241 Euro on 4th on July. Conversion rate in PLN for this date is 0,21314. So my outcome would be - Euro-SUper 95 on 4th of July cost 8.120519

I wonder if it's possible with DAX? I could create a conversion rate table and join it by date and then I guess it would work. 


simon139_0-1657888359631.png

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>> So let's say Bulgaria has price for Euro-Super 96 for 1,7241 Euro on 4th on July. Conversion rate in PLN for this date is 0,21314. So my outcome would be - Euro-SUper 95 on 4th of July cost 8.120519

please try this,

Column = 
var _Country="Bulgaria"
var _WeeklyPWPI=MAXX(FILTER('Table','Table'[Country Name]=_Country && 'Table'[Prices in force on]= EARLIER('Table'[Prices in force on]) && 'Table'[Product Name]= EARLIER('Table'[Product Name])),[Weekly Price with per I])
var _divide=DIVIDE(_WeeklyPWPI,'Table'[Euro exchange rate])
return IF('Table'[Country Name]="Poland", _divide)

vxiaotang_0-1658220747018.png

in this column code, _WeeklyPWPI returns 1,7241

vxiaotang_1-1658220826065.png

Best Regards,

Community Support Team _Tang

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

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>> So let's say Bulgaria has price for Euro-Super 96 for 1,7241 Euro on 4th on July. Conversion rate in PLN for this date is 0,21314. So my outcome would be - Euro-SUper 95 on 4th of July cost 8.120519

please try this,

Column = 
var _Country="Bulgaria"
var _WeeklyPWPI=MAXX(FILTER('Table','Table'[Country Name]=_Country && 'Table'[Prices in force on]= EARLIER('Table'[Prices in force on]) && 'Table'[Product Name]= EARLIER('Table'[Product Name])),[Weekly Price with per I])
var _divide=DIVIDE(_WeeklyPWPI,'Table'[Euro exchange rate])
return IF('Table'[Country Name]="Poland", _divide)

vxiaotang_0-1658220747018.png

in this column code, _WeeklyPWPI returns 1,7241

vxiaotang_1-1658220826065.png

Best Regards,

Community Support Team _Tang

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

Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.