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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
vinayguptak0520
Frequent Visitor

How to get Percentage at a Column by dividing from a specific Account

Hi everyone.  I have been struggling with a DAX calculation where I would like to get Percentage by Column.

    

 Actual Total Sales 

Percentage

 

Formula for %

40000

Sales

  

 $500,000.00

   
        

Sales Allowance

Allowances

  

 $88,350.00

17.67%

 

 E4/E$2 

56000

Advertising Expense

  

 $11,000.00

2.20%

 

E5/E$2

56100

Allowance

  

 $75,000.00

15.00%

 

E5/E$2

56200

Allowance-DefectiveGoods

  

 $500.00

0.10%

 

E6/E$2

56300

Discount

  

 $-  

0.00%

  

56400

Special Program

  

 $650.00

0.13%

  

56500

Cust Warehouse

  

 $-  

0.00%

  

56600

Freight Discount

  

 $1,200.00

0.24%

  

Sales Deductions

Deductions

  

 $3,890.00

0.78%

 

E12/E$2

38000

Deduction - Freight

  

 $-  

0.00%

  

38010

Customer Charge Back

  

 $-  

0.00%

  

38020

Other Customer Chargebacks

  

 $2,330.00

0.47%

  

38030

Drop Ship Errors

  

 $1,500.00

0.30%

  

38040

Deduction - Defective Goods

  

 $60.00

0.01%

  

38050

Shortage

  

 $-  

0.00%

  
        

Grand Total

   

 $407,760.00

81.55%

 

E20/E$2

 

I am trying to get the percentage calculated.  Take a specific Company's total sales (ie Amazon) = 500,000 and divide that by its sales to get the percentage.

Example: 88,350/500,000 = 17.67%

11,000/500,000 = 2.20%

vinayguptak0520_0-1711630268512.png

 

I've used this DAX but this only gives me the percentage of the Grand Total.

ActualPerct =
VAR _TotalSales40000Actual =
CALCULATE(
SUM('CustomerData'[Actual]),
'CustomerData'[Account] = 40000
)

VAR _TotalSales = SUM('CustomerData'[Actual])

VAR _Result =
DIVIDE(
SUM('CustomerData'[Actual]),
_TotalSales40000Actual,0
)

RETURN _Result

 

Any suggestions or guidance is highly appreciated.  Thank you

1 ACCEPTED SOLUTION

Thank you so much for your suggestion.  I did some minor tweaks and was able to get the results that I was looking for.

View solution in original post

13 REPLIES 13
vinayguptak0520
Frequent Visitor

Thank you so much for the suggestion.  Do I have to create the summary level in Power Query or can that be created in the report view using DAX to summarize the table?  The reason is that the raw data is at a daily level and will continue to grow.  Thank you.

It is impossible to do this in DAX, must be done even before Power Query.

I see.  This is what the raw data Excel file looks like.  I have to join multiple tables to get the Category and subcategories.

AccountFinDateCustomerVendorIDCustomerVendor Parent  NetAmt  Actual  Budget Customer Group
400001/6/2024C00088Walmart - CONSIGNMENTC00411-106.43-106.430.00Walmart
400001/6/2024C00088Walmart - CONSIGNMENTC00411-2131.16-2,131.160.00Walmart
400001/6/2024C00088Walmart - CONSIGNMENTC00411-3112.85-3,112.850.00Walmart
400001/6/2024C00088Walmart - CONSIGNMENTC00411-1540-1,540.000.00Walmart
400001/6/2024C00088Walmart - CONSIGNMENTC0041115.2415.240.00Walmart
400001/6/2024C00088Walmart - CONSIGNMENTC0041116741,674.000.00Walmart

 

Thank you.

you may not want to post your sensitive company data here. Post sample data only.

Those are sample data.  Thank you.

if that is the case can you provide them in a usable format, not as a screenshot?


Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Thank you for the suggestion.  I went ahead and reposted the raw data.  The only difference is that I have added the Financial date and parent name.  I took your logic and tried to incorporate that in the PBI example but the percentages are incorrect.  Also, there are multiple Groups.  This is just an example of 1 group.

 

ClassAccountFinDateCustomerVendorIDCustomerVendor Parent   Actual  Group
COGS350001/6/2024C00088Walmart - CONSIGNMENTC00411 $   1,020.00Walmart
COGS351002/10/2024C00088Walmart - CONSIGNMENTC00411 $       650.00Walmart
Sales400001/6/2024C00088Walmart - CONSIGNMENTC00411 $   2,451.00Walmart
Sales400001/6/2024C00088Walmart - CONSIGNMENTC00411 $   3,450.00Walmart
Sales400001/6/2024C00088Walmart - CONSIGNMENTC00411 $   1,500.00Walmart
Sales Allowance534501/6/2024C00088Walmart - CONSIGNMENTC00411 $       754.00Walmart
Sales Allowance534501/20/2024C00088Walmart - CONSIGNMENTC00411 $   1,245.00Walmart
Sales Allowance534501/15/2024C00088Walmart - CONSIGNMENTC00411 $     (115.00)Walmart
Sales Allowance534602/20/2024C00088Walmart - CONSIGNMENTC00411 $   1,240.20Walmart
Sales Discount254001/6/2024C00088Walmart - CONSIGNMENTC00411 $   1,540.00Walmart

 

Desired output.

vinayguptak0520_0-1711756964199.png

 

Is it due to the data being more granular?  Any suggestion?  Thank you.

Your Sales Discount number is off.

 

lbendlin_0-1711760427789.png

 

lbendlin_1-1711760448375.png

 

I had to introduce a sort column for the Class column.

 

lbendlin_2-1711760492184.png

 

Are you still performing group by in the power query?  Thanks.

no grouping. see attached.

Thank you so much for the suggestion.  I used your formula with my actual data and noticed that the Sales numbers are incorrect.  For example, it should say $400,000 but it's displaying $350,000.  Is it because I have a lot more data fields in the raw data set?

 

00_TEST_Actual =
VAR _TotalActuals = SUMMARIZE(SummaryData_TEST,[Account],[Actual])
RETURN
    SUMX(_TotalActuals,IF([Account] = 40000,[Actual],-[Actual]))
 
I appreciate all the help.

Thank you so much for your suggestion.  I did some minor tweaks and was able to get the results that I was looking for.

lbendlin
Super User
Super User

Your issue is not with the DAX but with the general structure of your data. It is in an Excel based user friendly format, but unusable for Power BI.  You need to clean that up first and then the DAX writes itself.

 

The Total Sales for example should ideally not be part of this table at all, it should come from a separate table.

 

Here's an example of how this would look like in Power BI:

lbendlin_0-1711651033729.png

 

lbendlin_1-1711652915471.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors