Forum Discussion
Calculating difference between consecutive rows
- Anonymous7 years ago
Hi socksinbox ,
It can be segment wise, you just create a table and drag the segment column into it,
then create the measue I did, then drag to it, you will see the result.
Or do you mean you want to use a DAX to create a new table with segment column and diff column?
Aiolos Zhao
- Anonymous7 years ago
Hi socksinbox ,
If you want to create a new table, please use below expression :
Table = SUMMARIZE(Table4,Table4[Segment],"Diff",CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Active") - CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Negative"))
Thanks.
Aiolos Zhao
- 7 years ago
Hi,
Based on the data that you have shared, the average should be 0. Try this measure
Measure = AVERAGEX(SUMMARIZE(CALCULATETABLE(Data,Data[PeopleType]="Active"||Data[PeopleType]="Negative"),Data[Segment],"Active",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Active"),"Negative",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Negative")),[Active]-[Negative])
Thanks Anonymous for this.
Actually this will calculate the overall difference, however, I would like to have segment wise difference. So I would need to return a table not a measure
thanks
Hi socksinbox ,
It can be segment wise, you just create a table and drag the segment column into it,
then create the measue I did, then drag to it, you will see the result.
Or do you mean you want to use a DAX to create a new table with segment column and diff column?
Aiolos Zhao
- socksinbox7 years ago
Helper I
Yes.. I mean I would like to create a new data table.
Actually, once I will have the segment-wise difference then I will create a measure on the top of that which will take the average of all differences and show in a card visualcheers
- Anonymous7 years agoNot applicable
Hi socksinbox ,
If you want to create a new table, please use below expression :
Table = SUMMARIZE(Table4,Table4[Segment],"Diff",CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Active") - CALCULATE(COUNTROWS(Table4),Table4[PeopleType] = "Negative"))
Thanks.
Aiolos Zhao
- socksinbox7 years ago
Helper I
Thanks Anonymous for your help
- Ashish_Mathur7 years ago
Super User
Hi,
Based on the data that you have shared, the average should be 0. Try this measure
Measure = AVERAGEX(SUMMARIZE(CALCULATETABLE(Data,Data[PeopleType]="Active"||Data[PeopleType]="Negative"),Data[Segment],"Active",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Active"),"Negative",CALCULATE(COUNTROWS(Data),Data[PeopleType]="Negative")),[Active]-[Negative])
- socksinbox7 years ago
Helper I
Thanks Ashish_Mathur for your help