Forum Discussion
Help with calculated column
Hi, I have this table, I want to grab the Monthly value of ID 1 :
And put it in a calculated column for every ID (taking into account the Month) like this:
How can I achieve this with DAX ?
Thanks
Hi Anonymous
what about this solution:
X = CALCULATE(SUM('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Month]),'Table'[ID] = 1))With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)Hi,
This calculated column formula works
=CALCULATE(SUM(Data[Value]),FILTER(Data,Data[ID]=1&&Data[Month]=EARLIER(Data[Month])))
Hope this helps.
3 Replies
- FrankATCommunity Champion
Hi Anonymous
what about this solution:
X = CALCULATE(SUM('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Month]),'Table'[ID] = 1))With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut) - Ashish_MathurSuper User
Hi,
This calculated column formula works
=CALCULATE(SUM(Data[Value]),FILTER(Data,Data[ID]=1&&Data[Month]=EARLIER(Data[Month])))
Hope this helps.
- darentengmfsPost Prodigy
Hi Anonymous
I know there's a faster way to do this but I do not know how, but this is how I would approach your problem.
- Create a new column, ID_New = 1, this will make all rows 1
- Change ID_New and ID columns data type into text
- Create 2 more new columns, ID_New-Month and ID-Month, with the formula ID_New-Month = concatenate(ID_New,Month) and ID-Month = concatenate(ID,Month)
- Once you have that, do a lookupvalue column. X = lookupvalue('Table'[Value], 'Table'[ID-Month], 'Table'[ID_New-Month])
As mentioned, there has to be a quicker way to do it, but this is how I would do it if I couldn't find the quick way.