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

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

Reply
Anonymous
Not applicable

Generating new table based on condition

Hi team, I am quite new to POWER BI so keen to know how to figure this out: 

I have a table below, what I am trying to do is finding the latest two Credit_rating records for each account( this is decided by last_process_time). 

Rachel_zzzz_0-1623971971172.png

I had created two columns to identify the latest two records, IsLastProday column and IsOldrecord column,

Rachel_zzzz_1-1623972672755.png

Now I want to get a table like below:, I am trying to use summarize function 

CreditChange = SUMMARIZE('table','table'[Account],"IslastProDay",if('table'[IsLastProDay]="Yes",'table'[Credit_rating]),"IsOldRecord",if('table'[IsOldrecord]="Yes",'table'[Credit_rating]))

Rachel_zzzz_2-1623972806992.png

but getting error saying the single Value of column 'Credit_rating' in table cannot be determined. 

 

Anyone have a better idea how can I get the table above?? thanks so much 🙂

 

 

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try this

Table 2 = 

VAR tbl=ADDCOLUMNS(SUMMARIZE('Table','Table'[Account],"last",CALCULATE(max('Table'[Last_process_time]),ALLEXCEPT('Table','Table'[Account])),"last2",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]<CALCULATE(max('Table'[Last_process_time]),ALLEXCEPT('Table','Table'[Account]))),'Table'[Last_process_time])),"isoldrecord",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]=[last]),'Table'[Credit_rating]),"islastproday",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]=[last2]),'Table'[Credit_rating]))
RETURN SUMMARIZE(tbl,'Table'[Account],[isoldrecord],[islastproday])

please see the attachment below.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
ryan_mayu
Super User
Super User

@Anonymous 

maybe you can try this

Table 2 = 

VAR tbl=ADDCOLUMNS(SUMMARIZE('Table','Table'[Account],"last",CALCULATE(max('Table'[Last_process_time]),ALLEXCEPT('Table','Table'[Account])),"last2",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]<CALCULATE(max('Table'[Last_process_time]),ALLEXCEPT('Table','Table'[Account]))),'Table'[Last_process_time])),"isoldrecord",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]=[last]),'Table'[Credit_rating]),"islastproday",maxx(FILTER('Table','Table'[Account]=EARLIER('Table'[Account])&&'Table'[Last_process_time]=[last2]),'Table'[Credit_rating]))
RETURN SUMMARIZE(tbl,'Table'[Account],[isoldrecord],[islastproday])

please see the attachment below.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.