Forum Discussion
case weighting in data
- 9 years ago
Okay, after a few trials and errors, and googling the DAX formulas, I might have worked it out. so in my case the formula I needed was, for displaying the average of a scale value (index value, ranging from 0 to 100):
MyWeightedMeasure = SUMX('TableName'; 'TableName'[WeightColumnName] * 'TableName'[ColumnName]) / SUM('TableName'[WeightColumnName])
I realized that this "workaround" was only necessary for displaying such an average value. For percentages, i.e. frequencies of groups that are represented by different names in one column, such as "male/female", you only need to put your column in the legend field, and your weight column in the value-field (I'm in the german version, I hope I translated the words correctly). But be careful, I think that only works right if your weights sum up to the total n of cases in your table.
This is an interesting link - but I don't get this working in PowerBI, I'm too "beginner" for that. Would you mind explaning the steps necessary for weighting cases in PowerBI? (e.g., the formula in the tableau tutorial is
SUM([Weight]) / TOTAL(SUM([Weight]))
Where do I type this formula? I tried creating a new measure, but it's not working (the word "total" doesn't exist as a formula in PowerBI, but that is only one of the problems). I was wondering where the connection to the target variable in the formula is? If I tried to analyse, say, gender proportions in my data, which would be unweighted 60% males 40% females, and the weighted values would be like 55% males and 45% females. I habe the required weight-Column in my data, but I can't imagine how to achieve that perhaps simple task...
Any help would be much appreciated,
Thanks,
Daniel
Okay, after a few trials and errors, and googling the DAX formulas, I might have worked it out. so in my case the formula I needed was, for displaying the average of a scale value (index value, ranging from 0 to 100):
MyWeightedMeasure = SUMX('TableName'; 'TableName'[WeightColumnName] * 'TableName'[ColumnName]) / SUM('TableName'[WeightColumnName])
I realized that this "workaround" was only necessary for displaying such an average value. For percentages, i.e. frequencies of groups that are represented by different names in one column, such as "male/female", you only need to put your column in the legend field, and your weight column in the value-field (I'm in the german version, I hope I translated the words correctly). But be careful, I think that only works right if your weights sum up to the total n of cases in your table.
- megm0019 years agoAdvocate II
Hi! I have the same issue. Can you give an example of applying a weight to an entire table?
Thanks!
- megm0019 years agoAdvocate II
Hi! I have the same issue. Can you give an example of applying a weight to an entire table?
Thanks!
- Anonymous7 years agoNot applicable
Bumping this, as I have been trying to follow your suggestion for using when frequencies of groups are represented by different names in the a column. I've been trying to use for my gender question, but get an error whenever I put the measure in the values bucket as suggested. Does anyone have any thoughts as to why this might be happening, and how to work around it?
Thanks in advance!
dani42 wrote:Okay, after a few trials and errors, and googling the DAX formulas, I might have worked it out. so in my case the formula I needed was, for displaying the average of a scale value (index value, ranging from 0 to 100):
MyWeightedMeasure = SUMX('TableName'; 'TableName'[WeightColumnName] * 'TableName'[ColumnName]) / SUM('TableName'[WeightColumnName])
I realized that this "workaround" was only necessary for displaying such an average value. For percentages, i.e. frequencies of groups that are represented by different names in one column, such as "male/female", you only need to put your column in the legend field, and your weight column in the value-field (I'm in the german version, I hope I translated the words correctly). But be careful, I think that only works right if your weights sum up to the total n of cases in your table.