Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Help with calculated column

Hi, I have this table, I want to grab the Monthly value of ID 1 :

 

 

11.png

 

And put it in a calculated column for every ID (taking into account the Month) like this:

 

22.png

 

How can I achieve this with DAX ?

 

Thanks

 

 

2 ACCEPTED SOLUTIONS
FrankAT
Community Champion
Community Champion

Hi @Anonymous 

what about this solution:

 

25-09-_2020_22-39-10.png

 

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)

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=CALCULATE(SUM(Data[Value]),FILTER(Data,Data[ID]=1&&Data[Month]=EARLIER(Data[Month])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=CALCULATE(SUM(Data[Value]),FILTER(Data,Data[ID]=1&&Data[Month]=EARLIER(Data[Month])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
FrankAT
Community Champion
Community Champion

Hi @Anonymous 

what about this solution:

 

25-09-_2020_22-39-10.png

 

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)

darentengmfs
Post Prodigy
Post 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.

 

  1. Create a new column, ID_New = 1, this will make all rows 1
  2. Change ID_New and ID columns data type into text
  3. 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)
  4. 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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.