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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
TomasPac
Helper I
Helper I

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
v-xicai
Community Support
Community Support

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 "%".

 

3.png

 

 

 

 

Best Regards,

Amy

 

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

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

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

v-xicai
Community Support
Community Support

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 "%".

 

3.png

 

 

 

 

Best Regards,

Amy

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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