Forum Discussion
shikhavidyarthi
3 years agoFrequent Visitor
# Expression error
I am creating a new custom column for a table with more than 30 columns. I am trying to create a new column with IF and ELSE Statement but getting the below error. Please let me know the correct sy...
- 3 years ago
Ah, ok.
You want to do this in DAX, not in Power Query. Create a DAX measure like this:
_Overr_ct_pct = VAR __idCount = COUNT(yourTable[Overr_ct]) VAR __total = CALCULATE( COUNT(yourTable[Overr_ct]), REMOVEFILTERS(yourTable), VALUES(yourTable[id]) ) RETURN IF( MAX(yourTable[Keep_num]) = 1, // If [Keep_num] is a measure you can remove the MAX() and 'yourTable' bits DIVIDE(__idCount, __total, 0) )Select this new measure from the Fields list, go to the Measure Tools tab, change the format to Percent:
Pete
shikhavidyarthi
3 years agoFrequent Visitor
Hi,
I want the result as bottom screenshot.
- BA_Pete3 years ago
Super User
Ah, ok.
You want to do this in DAX, not in Power Query. Create a DAX measure like this:
_Overr_ct_pct = VAR __idCount = COUNT(yourTable[Overr_ct]) VAR __total = CALCULATE( COUNT(yourTable[Overr_ct]), REMOVEFILTERS(yourTable), VALUES(yourTable[id]) ) RETURN IF( MAX(yourTable[Keep_num]) = 1, // If [Keep_num] is a measure you can remove the MAX() and 'yourTable' bits DIVIDE(__idCount, __total, 0) )Select this new measure from the Fields list, go to the Measure Tools tab, change the format to Percent:
Pete