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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Sum of counts Previous+Current Value by Group

Here is the Sample i have. I have data by Quarters wanted to calculate (Current Quat Count + Previous Quat Count) / 2 which is working Good. My challenge is i want to display the sum of all the values for each category. Below is the Formula i am using 

 

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]))

 

Sample.PNG

Here is what i want : 

1. Sum of counts from the above values by Category,  It should sum all the values displayed in Quarters . For Column B ,C 

2. Total : Sum of Values by Quarter * Weight  = Sum of Quarters in Each category = Sum  = For column d


desired output.PNG

 

 

 

below is the sample data 

 

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.4
14Cloths1/1/2019Good0.4
15Cloths1/1/2019Bad0.4
16Cloths1/1/2019Verygood0.4
17Cloths1/1/2019Verygood0.4
18Cloths4/1/2019Good0.5
19Cloths4/1/2019Good0.5
20Cloths4/1/2019Good0.5
21Cloths4/1/2019Verygood0.5
22Cloths4/1/2019Verygood0.5
23Cloths4/1/2019Bad0.5
24Cloths4/1/2019Bad0.5
25Cloths4/1/2019Bad0.5
26Cloths7/1/2019Verygood0.3
27Cloths7/1/2019Verygood0.3
28Cloths7/1/2019Bad0.3
29Cloths7/1/2019Bad0.3
30Cloths7/1/2019Bad0.3

 

Thanks in Advance

Status: New
Comments
v-chuncz-msft
Community Support

@RevD 

 

You may use ISINSCOPE to detect the level and SUMX to get the total.

https://www.sqlbi.com/articles/obtaining-accurate-totals-in-dax/

RevD
Frequent Visitor

I was able to achive this 

2. Total : Sum of Values by Quarter * Weight  = Sum of Quarters in Each category = Sum  = For column d

 

But i am not able to get this, Can you provide Dax 

 

_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