cancel
Showing results for
Did you mean:
Highlighted
TomasPac Frequent Visitor

## Hiw to get percentage column

Hello, I have a table which shows sales, purchases, and profit (sales minus purchases) grouped by date column. Table is related to a different table which has site names. So by that i calculate how much each site spends and makes sales. What  I need is a new column which would show percentage of purchases against sales. The syntax would look something like sales minus purchases = profit divided by sales which is 100% and I need everything shown in %. Thank You

1 ACCEPTED SOLUTION

Accepted Solutions
v-xicai Super Contributor

## Re: Hiw to get percentage column

Hi @TomasPac ,

Assuming the table which shows sales, purchases, and profit is named Table1, and the table which has site names is named Table2.

Based on having created relationship between the two tables, and set the Cross filter direction as Both, which will treat these tables as a single table ,you can create column and measure like DAX below in Table1.

Column: profit =[sales] - [purchases]

Measure: percentage= DIVIDE (CALCULATE(SUM(Table1[profit]),FILTER(ALLSELECTED(Table2), Table2[site names] =MAX(Table2[site names]))), CALCULATE(SUM(Table1[profit]),FILTER(ALLSELECTED(Table2), Table2[site names] =MAX(Table2[site names]))))

Then click on the field [percentage] in Field pane, set it showed "%". Best Regards,

Amy

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

2 REPLIES 2
v-xicai Super Contributor

## Re: Hiw to get percentage column

Hi @TomasPac ,

Assuming the table which shows sales, purchases, and profit is named Table1, and the table which has site names is named Table2.

Based on having created relationship between the two tables, and set the Cross filter direction as Both, which will treat these tables as a single table ,you can create column and measure like DAX below in Table1.

Column: profit =[sales] - [purchases]

Measure: percentage= DIVIDE (CALCULATE(SUM(Table1[profit]),FILTER(ALLSELECTED(Table2), Table2[site names] =MAX(Table2[site names]))), CALCULATE(SUM(Table1[profit]),FILTER(ALLSELECTED(Table2), Table2[site names] =MAX(Table2[site names]))))

Then click on the field [percentage] in Field pane, set it showed "%". Best Regards,

Amy

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

v-xicai Super Contributor

## Re: Hiw to get percentage column

Hi  @TomasPac ,

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

Best regards

Amy