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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bbbt123
Helper I
Helper I

help with calculated column

Hello, I need help with a calculated column.   I have a table, call it "Table1" with unique values per category, see example below:

category value
a30
b40
c50

 

Then I have another table, call it "Table2" like the one below:

 

week numcategoryvalue
10a34
11b45
12a67
13b89

 

I have to create a new column in Table 2 where I add the corresponding value of Table 1 only once, only in the first row, not in each row. how can I achieve it in power bi?

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

I am thinking perhaps:

 

Column in Table2 = 
  VAR __Category = [category]
  VAR __MinWeek = MINX(FILTER(ALL('Table2'),[category]=__Category),[week num])
RETURN
  IF([week num] = __MinWeek,LOOKUPVALUE('Table1'[value],'Table1'[category],__Category),BLANK())


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

I am thinking perhaps:

 

Column in Table2 = 
  VAR __Category = [category]
  VAR __MinWeek = MINX(FILTER(ALL('Table2'),[category]=__Category),[week num])
RETURN
  IF([week num] = __MinWeek,LOOKUPVALUE('Table1'[value],'Table1'[category],__Category),BLANK())


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Create these two new columns in table 2

Count = countx(filter(table2,table2[category]=earlier(table2[category]) && table2[week num] <=earlier(table2[week num])),table2[week num])

from table 1 = maxx(filter(table1,table2[category]=(table1[category]) && table2[Count]=1),table1[value])

 

Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.