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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jader3rd
Microsoft Employee
Microsoft 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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.