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
ccarpent
Helper IV
Helper IV

DAX, calculate percentages based on date or selected results

Hi

 

I am struggling a little with what should be a simple percentage calculation.  I am doing this with DAX, but I am using Excel PowerPivot so I hope you don't mind me posting this question here.  I seem to be getting the calcualtion correct based on each row, but the comparison aganist the total when based selevct justa few members not working.

 

My data is basically repeated every few days, and then I use a pivot/matrix to make a selction based on 'DateChecked'

 

DataSetDataSet

 

So when I select a date, the matric works out the percentages correctly, see column 'TotalComparison%' this is the entire list for 01/10/2022.

Result when all selectedResult when all selected

 

However when I just focus say two people for example, the 'TotalComparison%' calculation is now based on currennt selection and not the orginal total mentioend above.

result when I select two for exampleresult when I select two for example

 

Any help approciated, and sampe data posted here:

 

DateCheckedNameTotalNoTasksTotalFinishedTotalToBeDoneTotalNotFinished
01/10/2022JOHN12309
01/10/2022PAUL150015
01/10/2022ARTHUR243156
01/10/2022CHARLES10703
01/10/2022SARA9306
01/10/2022FIONA2712312
15/10/2022JOHN183015
15/10/2022PAUL181233
15/10/2022ARTHUR15663
15/10/2022CHARLES3003
15/10/2022SARA3030
15/10/2022FIONA3030
01/11/2022JOHN6330
01/11/2022PAUL3030
01/11/2022ARTHUR3613149
01/11/2022CHARLES12606
01/11/2022SARA9333
01/11/2022FIONA3300
17/11/2022JOHN3003
17/11/2022PAUL181143
17/11/2022ARTHUR12093
17/11/2022CHARLES3300
17/11/2022SARA3915321
17/11/2022FIONA3003

 

 

Many thanks

ChrisC

 

 

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @ccarpent ,

 

This is my test table:

vyadongfmsft_0-1668759031744.png

 

I create following columns:

TotalFinshed% = DIVIDE('Table'[TotalFinished],'Table'[TotalNoTasks])

TotalToBeDone% = DIVIDE('Table'[TotalToBeDone],'Table'[TotalNoTasks])

TotalNotFinished% = DIVIDE('Table'[TotalNotFinished],'Table'[TotalNoTasks])

TotalComparison% = 
var sum_notasks = CALCULATE(SUM('Table'[TotalNoTasks]),ALLEXCEPT('Table','Table'[DateChecked]))
return
DIVIDE('Table'[TotalNoTasks],sum_notasks)

vyadongfmsft_1-1668759119803.png

 

I think this is the result you want:

vyadongfmsft_2-1668759160437.png

vyadongfmsft_3-1668759185742.png

 

When you select two people:

vyadongfmsft_4-1668759215535.png

vyadongfmsft_5-1668759281344.png

 

Best regards,

Yadong Fang

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-yadongf-msft
Community Support
Community Support

Hi @ccarpent ,

 

This is my test table:

vyadongfmsft_0-1668759031744.png

 

I create following columns:

TotalFinshed% = DIVIDE('Table'[TotalFinished],'Table'[TotalNoTasks])

TotalToBeDone% = DIVIDE('Table'[TotalToBeDone],'Table'[TotalNoTasks])

TotalNotFinished% = DIVIDE('Table'[TotalNotFinished],'Table'[TotalNoTasks])

TotalComparison% = 
var sum_notasks = CALCULATE(SUM('Table'[TotalNoTasks]),ALLEXCEPT('Table','Table'[DateChecked]))
return
DIVIDE('Table'[TotalNoTasks],sum_notasks)

vyadongfmsft_1-1668759119803.png

 

I think this is the result you want:

vyadongfmsft_2-1668759160437.png

vyadongfmsft_3-1668759185742.png

 

When you select two people:

vyadongfmsft_4-1668759215535.png

vyadongfmsft_5-1668759281344.png

 

Best regards,

Yadong Fang

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

daXtreme
Solution Sage
Solution Sage

What's the formula you use for TotalComparison%? I understand you've created a measure to calculate this and not using the automatically created measures? Because if you do, the output you get is precisely what you should expect. You cannot achieve what you want by using automatically generated formulas. You have to code it yourself.

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