Forum Discussion
Assign Column Value to a Variable
Hi,
I am trying to create a variable that contains the values in one of my table columns. For example, I have column called Category Number which assigns a text column a number ranging from 1-13. I would like to create a variable that contains all 1-13 values. I thought I could use this as my variable:
- Anonymous4 years ago
Hi Anonymous ,
VALUES() function returns a table.
You could add a column or create a measure to get the sum of sales:
Column = CALCULATE(SUM('2021_Data'[Sales]),FILTER('2021_Data',[CAT]=EARLIER('Table'[CAT]))) Measure = CALCULATE(SUM('2021_Data'[Sales]),FILTER('2021_Data',[CAT]=MAX('Table'[CAT])))Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
Anonymous , If you looking to use slicer values then you can not do that in a new column
to you have 13 static columns
1= CALCULATE('2021_Data'[2021AllSales],FILTER('2021_Data','2021_Data'[Category Number]=1) )
or
you can measures
CALCULATE(sum('2021_Data'[2021AllSales]) ,FILTER('2021_Data','2021_Data'[Category Number]=1)
for measure you can use field parameters or calculation group to select
Calculation Groups- Measure Slicer, Measure Header Grouping, Measure to dimension conversion. Complex Table display : https://youtu.be/qMNv67P8Go0
- AnonymousNot applicable
Hi Anonymous ,
VALUES() function returns a table.
You could add a column or create a measure to get the sum of sales:
Column = CALCULATE(SUM('2021_Data'[Sales]),FILTER('2021_Data',[CAT]=EARLIER('Table'[CAT]))) Measure = CALCULATE(SUM('2021_Data'[Sales]),FILTER('2021_Data',[CAT]=MAX('Table'[CAT])))Output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Hi Anonymous this is exactly what I was looking for, thank you so much for your help!