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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
RevD
Frequent Visitor

Multiply percent of column total with a value in each group

Need Help 

 

i want to mutiply the Percent of column total in each category with Weight value in each category by Quarters 

Current Quat Count =COUNT(Sheet1[Index]) 

Previous = IF(HASONEVALUE(Sheet1[DateCustom]),CALCULATE([Counts],VALUES(Sheet1[Category ]),DATEADD(Sheet1[DateCustom],-1,QUARTER)),blank())

overallCounts = ([Counts]+[Previous]) / (2 - ISBLANK([Counts]) - ISBLANK([Previous]))

 

Percent of column total of : Overalltotal is displayed below 

 

current.PNG

 

2019 - 01 = 20%*60% + 25%*40% 

2019 - 04 = 31% *30% + 38%*50% 

 

and display the final output like this format : 

 

Finaloutput.PNG

 

Below is the data set

IndexCategory DateCustomRatingWEIGHT
1Food1/1/2019Good0.4
2Food1/1/2019Good0.4
31Food1/1/2019Bad0.4
3Food1/1/2019Verygood0.4
4Food4/1/2019Verygood0.5
5Food4/1/2019Verygood0.5
6Food4/1/2019Bad0.5
7Food4/1/2019Bad0.5
8Food7/1/2019Verygood0.3
9Food7/1/2019verygood0.3
10Food7/1/2019Bad0.3
11Food7/1/2019Bad0.3
12Food7/1/2019Bad0.3
13Cloths1/1/2019Good0.6
14Cloths1/1/2019Good0.6
15Cloths1/1/2019Bad0.6
16Cloths1/1/2019Verygood0.6
17Cloths1/1/2019Verygood0.6
18Cloths4/1/2019Good0.3
19Cloths4/1/2019Good0.3
20Cloths4/1/2019Good0.3
21Cloths4/1/2019Verygood0.3
22Cloths4/1/2019Verygood0.3
23Cloths4/1/2019Bad0.3
24Cloths4/1/2019Bad0.3
25Cloths4/1/2019Bad0.3
26Cloths7/1/2019Verygood0.2
27Cloths7/1/2019Verygood0.2
28Cloths7/1/2019Bad0.2
29Cloths7/1/2019Bad0.2
30Cloths7/1/2019Bad0.2
1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @RevD ,

 

We can create a measure to meet your requirement.

 

1. First we need to create a calculate column to judge Top or Bottom.

 

Rating(Groups) = IF([Rating] in {"Good","Verygood"},"Top","Bottom")

 

M 1.jpg

 

2. Then we can create a measure to get the result.

 

Current Quat Count = 
var Cloth_weight = CALCULATE(MIN(Sheet1[WEIGHT]),FILTER(Sheet1,Sheet1[Category] = "Cloths"))
var Food_weight = CALCULATE(MIN(Sheet1[WEIGHT]),FILTER(Sheet1,Sheet1[Category] = "Food"))
var Count_Cloth = CALCULATE(COUNT(Sheet1[Index]),FILTER(Sheet1,Sheet1[Category]="Cloths"))
var Count_food = CALCULATE(COUNT(Sheet1[Index]),FILTER(Sheet1,Sheet1[Category]="Food"))
var Count_Allselected_cloth = CALCULATE(COUNT(Sheet1[Index]),FILTER(ALLEXCEPT(Sheet1,Sheet1[DateCustom]),Sheet1[Category]="Cloths"))
var Count_Allselected_food = CALCULATE(COUNT(Sheet1[Index]),FILTER(ALLEXCEPT(Sheet1,Sheet1[DateCustom]),Sheet1[Category]="Food"))
var Cloth_percentage = Count_Cloth / Count_Allselected_cloth
var food_percentage = Count_food / Count_Allselected_food
return
food_percentage*Food_weight + Cloth_percentage*Cloth_weight

 

M 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

3 REPLIES 3
v-zhenbw-msft
Community Support
Community Support

Hi @RevD ,

 

We can create a measure to meet your requirement.

 

1. First we need to create a calculate column to judge Top or Bottom.

 

Rating(Groups) = IF([Rating] in {"Good","Verygood"},"Top","Bottom")

 

M 1.jpg

 

2. Then we can create a measure to get the result.

 

Current Quat Count = 
var Cloth_weight = CALCULATE(MIN(Sheet1[WEIGHT]),FILTER(Sheet1,Sheet1[Category] = "Cloths"))
var Food_weight = CALCULATE(MIN(Sheet1[WEIGHT]),FILTER(Sheet1,Sheet1[Category] = "Food"))
var Count_Cloth = CALCULATE(COUNT(Sheet1[Index]),FILTER(Sheet1,Sheet1[Category]="Cloths"))
var Count_food = CALCULATE(COUNT(Sheet1[Index]),FILTER(Sheet1,Sheet1[Category]="Food"))
var Count_Allselected_cloth = CALCULATE(COUNT(Sheet1[Index]),FILTER(ALLEXCEPT(Sheet1,Sheet1[DateCustom]),Sheet1[Category]="Cloths"))
var Count_Allselected_food = CALCULATE(COUNT(Sheet1[Index]),FILTER(ALLEXCEPT(Sheet1,Sheet1[DateCustom]),Sheet1[Category]="Food"))
var Cloth_percentage = Count_Cloth / Count_Allselected_cloth
var food_percentage = Count_food / Count_Allselected_food
return
food_percentage*Food_weight + Cloth_percentage*Cloth_weight

 

M 2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

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

thank you the solution is working 

 

One more help on this : But i am not able to get this, Can you provide Dax. below is the DAX i use

 

_Count = CALCULATE(COUNTX(Sheet1,Sheet1[Index]),FILTER(Sheet1,NOT(ISBLANK(Sheet1[Index]))))
_PreviousCounts = IF(HASONEVALUE(Sheet1[DateCustom]),
CALCULATE([_Count],VALUES(Sheet1[Category]),DATEADD(Sheet1[DateCustom],-1,QUARTER))
,BLANK())
_AccuracyRollingAvg = ([_Count ]+[_PreviousCounts ] )/
(2-ISBLANK([_Count ])-ISBLANK([_PreviousCounts ]))
 
Currently i use this _AccuracyRollingAvg to display by Quarters for each Category and it works good. In the new table i want to display sum of _AccuracyRollingAvg by Category  like below. Is it possible to use _AccuracyRollingAvg in Sumx
 
Capture.PNG
 
RevD
Frequent Visitor

The user wanted to display Quarters in Q1 2019 and so on. so created a date table and did calculation. I wanted to calculate the percent of column total which is not working. 

 

Below is the code i am using in Steps :

counts = CALCULATE(COUNTX(Sheet1,Sheet1[Index]),FILTER(Sheet1,NOT(ISBLANK(Sheet1[Index]))))
PreviousCounts = IF(HASONEVALUE(Sheet1[DateCustom]),
CALCULATE([counts],VALUES(Sheet1[Category]),PREVIOUSQUARTER('Date'[FullDate]))
,BLANK())
RollingAvg = ([counts]+[PreviousCounts] )/
(2-ISBLANK([counts])-ISBLANK([PreviousCounts]))
 
1. i want to get the Total of each column display in row, This is not working 
ClothsOverallcounts = CALCULATE(
    [RollingAvg],
    Sheet1[Category] IN { "cloths" },ALLEXCEPT('dATE','dATE'[Format_QuarterShort_YYYY]))
 
In this example for q1-2019 Cloths i want to display 5 in all rows for ClothsOverallcounts. Basically i want to get the % of column total and multiply with Weighted percent 60%
 
Capture.PNG
 
2. How to achive Sum of RollingAvg quaters by Category. Currently it just gives the of count by categorys 
 
Capture.PNG

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors