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
SRP
Frequent Visitor

How to fill a column with a if condition

I'm looking to understand how to filldown (or up) a column with a if condition, using PowerBI.  As you can see i have a "string_values" with null values. When the instance are the same (same number), i want to fill the string values. UPrvp6g.png

I tried this code but he doesn't work : 

 

New =
IF (
Sheet1[string_value] = BLANK ();
CALCULATE (
LASTNONBLANK ( Sheet1[string_value]; Sheet1[string_value] );
FILTER ( ALLEXCEPT ( Sheet1; Sheet1[instance] ); Sheet1[string_value] = EARLIER ( Sheet1[string_value] ) );
 
Sheet1[string_value]
)
 
Thanks for your help
1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@SRP 

is this what you want?

Column = 
VAR _text=maxx(FILTER(asmt_assessment_instance_question,asmt_assessment_instance_question[instance.task_id.number]=EARLIER(asmt_assessment_instance_question[instance.task_id.number])),asmt_assessment_instance_question[string_value])
return _text

1.PNG





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

Proud to be a Super User!




View solution in original post

9 REPLIES 9
v-jingzhang
Community Support
Community Support

Hi @SRP 

 

@ryan_mayu 's solution should work. Have you tried it? If you have solved it, accept a proper reply as solution or share your own solution if there is a better one. This will help the community! Thank you.

 

Best Regards,
Community Support Team _ Jing

ryan_mayu
Super User
Super User

@SRP 

is this what you want?

Column = 
VAR _text=maxx(FILTER(asmt_assessment_instance_question,asmt_assessment_instance_question[instance.task_id.number]=EARLIER(asmt_assessment_instance_question[instance.task_id.number])),asmt_assessment_instance_question[string_value])
return _text

1.PNG





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

Proud to be a Super User!




SRP
Frequent Visitor

Exactly !

SRP
Frequent Visitor

In first i saw only the screen and not the column. When i try it, the error is : 

 

"EARLIER/EARLIEST refers to an earlier row context which doesn't exist"

@SRP 

are you using a DAX to create a column? 





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

Proud to be a Super User!




SRP
Frequent Visitor

I tried with DAX yes but it doesn't work either. But i almost did it with Power Query, still doesn't work anyway

@SRP 

pls see the attachment below.





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

Proud to be a Super User!




amitchandak
Super User
Super User

@SRP , You have fill up and fill down option in power query.

 

You are using a dax column, there the logic needs to be based on column have to value.

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

I don't really know how to share that, but i got you a excel file with usefull data here : 

 

https://we.tl/t-usWasFJpdH

 

I tried to do it with Power Query but i can't incorporate the if condition with

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.