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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

HI @Anonymous ,

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
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @Anonymous ,

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
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

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

HI @Anonymous ,

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
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors