Forum Discussion
New Column With Switch Statement Errors
I think there was another visual causing errors. So I started over on another tab, and put this in like you mentioned:
GACategory =
VAR GAs = sumx(VALUES('Location'[Location]),[Gross Adds])
REturn
SWITCH(
TRUE(),
GAs<=45,"Low",
GAs>=45 && GAs<=70,"Mid",
GAs>70, "High"
)Now I'm getting "this query uses more memory than the limit". So it may be that I need to query it down further? Not certain but the same thing works perfect in a measure.
Your used functions are quite memory-intensive especially with large datasets. Anyway, if possible please share pbix. Without knowing what you are trying to achieve it is hard to give solution.
Solution provided earlier was not any concreate solution. Just want you to remember, that calculated column works row by row. It checks that the current row satisfy condition, if, then put it in calculation.
I don't know about your [Gross Adds] measure or it is a column or not. You are summing up gross adds for each location and then compare value to tagging each row (In which table). So, what is the relation between each row (where this column will be developed) and the gross adds, not very clear.
For example, I have a product table with price column where each row is a complete product info. I want to tag price with Low, Mid and High. I would then do simple:
Category =
SWITCH (
TRUE(),
Product[Price] <= 100, "Low",
Product[Price] > 100 && Product[Price] <= 500, "Mid",
"High"
)