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
jader3rd
Employee
Employee

Weighted percentage within the Date Hierarchy

I have a table where the columns are TimeSlice, CheckFailed and CNT. TimeSlice is a timestamp aggregated to the hour, CheckFailed is a label, and the CNT is the count of faile checks for the TimeSlice/hour.

In a Matrix, when I use the TimeSlice as the Rows, CheckFailed as the Columns I want the weighted percentage to be the value. So for the day Day row the WeightPct should be the percentage of the count the given CheckFailed had for the day, and for the Month row the WeightPct should be the percentage of the count the given CheckFailed had for the Month. Same goes for Quarter and Year.

I do this in SQL with

SUM(CNT) \ SUM(CNT) OVER (PARTITION BY CONVERT(DATE, TimeSlice)) AS WeightedPct

.

 

The closest I can get in DAX is

WeightedPct = SUMX(HABcs, [CNT]) / SUMX(FILTER(HABcs, HABcs[TIMESLICE]), SUM(HABcs[CNT]))

What I need is the sum of all CNT's for the Scope (all CNT's for a specific CheckFailed in a given TimeSlice grouping (day or month)), divided by the sum of all CNT's for the given TimeSlice grouping regardless of CheckFailed.

 

1 ACCEPTED SOLUTION

Hi,

 

It will only open the column specified in the ALL function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

Does this work?

 

=SUM(HABcs[CNT])/CALCULATE(SUM(HABcs[CNT]),ALL(HABcs[CheckFailed]))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Doesn't ALL break out to the whole table, and not restrict it to the current date grouping?

Hi,

 

It will only open the column specified in the ALL function.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That did it. Any pointers I can read up on as to why?

 

And thank you very much.

You are welcome.  The ALL() function will clear the filter of the column provided as an input but within the current filter context only.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.