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

Dax to calculate sum of a category divided by each line item.

Hi Need Help

i want to create a dax which gives percentage distribution of data for example

I have a measure which gives me total invoice. This invoice is distributed with a date category of 01-15, 15-30 so on till +91 days. this category is created using column. I want to calculate total sum of each category divided by invoice line item.

suppose i have categ data as this :-

categ                                   sum

0-15 days123456
15-30 days34545353
31-60 days676456
60-90 days2454657
91 days98978768

 

and invoice data as:

 

invoice itempricecateg
12454540-15 days
23676760-15 days
4545344331-60 days
675565715-30 days

No i want to take sum of table 1 category wise and divide it to each line itme according to its category.

2 REPLIES 2
kentyler
Solution Sage
Solution Sage

You should be able to create a relationship between your 2 tables on the categ column. It will be one to many with invoice data on the many side. you can access values from the one side of a relationship in calculations you do for the many side by using the dax function RELATED()

quoting from https://docs.microsoft.com/en-us/dax/related-function-dax

 

The RELATED function requires that a relationship exists between the current table and the table with related information. You specify the column that contains the data that you want, and the function follows an existing many-to-one relationship to fetch the value from the specified column in the related table. If a relationship does not exist, you must create a relationship.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

Hi sharing a sample dataset for this with the desired output aslo in that mail. which will help you to understand better. In this sample dataset the firs sheet is invoice sheet which will have invoice details second sheet is exchnage which has date, from currency and currency rates. Now third sheet has spend made by vendor and last sheet has spend by group i.e., 0-15 days and such that. 0-15 days etc. grouping are made by DAX using formulas so i want to devide total amount of spend category by means if the spend date of vendor falls in the cateogry of 0-15 then total sum of 0-15 days spend divided by that vendor spend.

 

Invoice table

Invoice NumberDatevendor  Numbervendor payment terms daysVendor Payment GroupingInvoice  payment terms daysCurrencyAmount
112320191001ABC300-3010USD100
112420191002ABC300-3020BRL200
112520191003ABC300-3030INR300
112620191004DEF4531-4510USD200
112720191005DEF4531-4520BRL250
112820191006DEF4531-4545INR50
112920191007GH6046-6020BRL100
113020191008GH6046-6060BRL150

 

exchange table

DateFrom CurrencyFx rates
20191001USD1
20191001BRL1.2
20191001INR1.4
20191002USD1
20191002BRL1.2
20191002INR1.4
20191003USD1
20191003BRL1.2
20191003INR1.4
20191004USD1
20191004BRL1.2
20191004INR1.4
20191005USD1
20191005BRL1.2
20191005INR1.4
20191006USD1
20191006BRL1.2
20191006INR1.4
20191007USD1
20191007BRL1.2
20191007INR1.4
20191008USD1
20191008BRL1.2
20191008INR1.4

 

spend by vendor 

ABC600
DEF500
GH250

 

spend by group

0-15600
31-45500
46-60250

 

now if vendor DEF spend fallls in category 0f 0-15 days i want def spend i.e, 500 devided by 0-15 days spendi.e, 600 which total is coming using a measure.

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