cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
jstern1 Frequent Visitor
Frequent Visitor

Filter Costs by Region, or Update Query Data with Proper Costs Column

Hi Everyone,

 

I could use some help in figuring out how to best find the aggregate costs of goods sold based on region.

 

Say a good costs $1 in the US, $2 in Europe, and $3 in Asia. Each specific sale is a separate row in my data set, however the cost of the good is not directly mapped to the sale based on region. I have a column that states which sale the region was made, but for the cost, I have separate columns for the $1, $2, and $3(the US Cost column has $1 for every row, Europe shows $2 for every row, etc.) . Is there a way to connect the proper cost for each sale in a single column (i.e. if the sale was in Europe, it will know to make the cost column say $2)? Or, is there an M code to filter it by cost based on region?

 

Thanks!   

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Filter Costs by Region, or Update Query Data with Proper Costs Column

HI @jstern1 ,

Power bi not suitable to calculate across multiple fields, I'd like to suggest you enter the query editor and use unpivot columns feature to convert these cost fields to attribute and value.

Unpivot columns (Power Query)
After these steps, you can simple filter on region attribute or write formula to calculate based on current category group.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Filter Costs by Region, or Update Query Data with Proper Costs Column

Hi @jstern1 ,

Please share some sample data with expect result to help us clarify your requirement and do test to coding formula.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
jstern1 Frequent Visitor
Frequent Visitor

Re: Filter Costs by Region, or Update Query Data with Proper Costs Column

Hi v-shex,

 

For example, I have the costs for each region placed in separate columns (EMEA = EU and APAC = AP - in the region column). Is there a way I can make a new column that assigns the appropriate cost for each row depending on the region, rather than having three separate columns? Or is there an M code that can filter it out at a later stage?

 

Thanks!

 

Capture.PNG

Community Support Team
Community Support Team

Re: Filter Costs by Region, or Update Query Data with Proper Costs Column

HI @jstern1 ,

Power bi not suitable to calculate across multiple fields, I'd like to suggest you enter the query editor and use unpivot columns feature to convert these cost fields to attribute and value.

Unpivot columns (Power Query)
After these steps, you can simple filter on region attribute or write formula to calculate based on current category group.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI

View solution in original post

Helpful resources

Announcements
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)