Forum Discussion
Newcolator
Helper II
1 year agoPutting a table and column name into a variable
Hi! This is doing my head in, maybe because it's not possible. I've got this DAX: Filter Test = VAR AvailableValuesList = CALCULATETABLE(VALUES(DIM_GROUP[Channel]), REMOVEFILTERS(DIM_GROUP[...
- 1 year ago
just so I understand, you are hoping for a user defined function with column name as parametrs in dax. Something like
// Function to sum up values in a specified column function sumColumn(data, column) { return data.reduce((sum, row) => sum + (row[column] || 0), 0); } // Example usage const data = [{'colA': 1, 'colB': 2}, {'colA': 3, 'colB': 4}]; const sumColA = sumColumn(data, 'colA'); const sumColB = sumColumn(data, 'colB'); console.log(`Sum of colA: ${sumColA}`); // Output: Sum of colA: 4 console.log(`Sum of colB: ${sumColB}`); // Output: Sum of colB: 6But I don't think in the current capacity of dax, this is possible. However, there is a buzz about udf coming to dax. Not sure what functionalities it will offer.
smpa01
Community Champion
1 year agojust so I understand, you are hoping for a user defined function with column name as parametrs in dax. Something like
// Function to sum up values in a specified column
function sumColumn(data, column) {
return data.reduce((sum, row) => sum + (row[column] || 0), 0);
}
// Example usage
const data = [{'colA': 1, 'colB': 2}, {'colA': 3, 'colB': 4}];
const sumColA = sumColumn(data, 'colA');
const sumColB = sumColumn(data, 'colB');
console.log(`Sum of colA: ${sumColA}`); // Output: Sum of colA: 4
console.log(`Sum of colB: ${sumColB}`); // Output: Sum of colB: 6
But I don't think in the current capacity of dax, this is possible. However, there is a buzz about udf coming to dax. Not sure what functionalities it will offer.
- Newcolator1 year ago
Helper II
Yes, that would be very useful. If it's not possible at the moment that's fine. I will stop trying to make it work! Thanks.