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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
vmurali1
Frequent Visitor

Requesting help with DAX Calculation

Team, 
I have a matrix where i am trying to calculate cost per case. The formula for that would be - Total Product Cost / Total# of Cases. I created two measures. One to sum the total product cost and another to calculate distinct count of the cases and then created a third measure called cost per case utilizing the two measures for numerator and denominator.

Now, if you look at the Category D in the attached snapshot, it calculates the total product cost  of each of the items in the drill down and takes the distinct number of cases where that item had been utilized - Which is correct but, is there any way i can have the denominator constant (Total # of cases by distinct names and by year since i might be adding a slicer for year in the future)? 

For example, if i breakdown the 3164.91, i should be able to see the breakdown of what comprises to 3614.91 rather than an average. In other words, i want the product cost of each item divided by the total # of cases for each names. 

 

Can someone assist me with this ?

 

Thanks in advance

PBIC.PNG

The data structure looks like this

pbic 2.PNG

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hello @vmurali1 if you want the #cases to be constant by year, you can try to first create a new column year with formula

Year= YEAR(table[case date])

Then create a new measure

# cases by year = Calculate(distinctcount[column you want],allexcept(table,table[Year]))

View solution in original post

Anonymous
Not applicable

If you want the # cases by year according to column "name" then just do 

 

# cases by year = Calculate(count(table[name],allexcept(table,table[Year],table[name]))

View solution in original post

4 REPLIES 4
vmurali1
Frequent Visitor

Actually, i got the logic and it worked perfect. Thanks for the guidance. 

Anonymous
Not applicable

Hello @vmurali1 if you want the #cases to be constant by year, you can try to first create a new column year with formula

Year= YEAR(table[case date])

Then create a new measure

# cases by year = Calculate(distinctcount[column you want],allexcept(table,table[Year]))

Thank you for the response but, i want the number of cases to be constant by name (first col) and year. 

Anonymous
Not applicable

If you want the # cases by year according to column "name" then just do 

 

# cases by year = Calculate(count(table[name],allexcept(table,table[Year],table[name]))

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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