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

Problem creating a column filtering two other columns on same table

Hello community!

 

I have a custom column with dates and would like to make a copy of this same column but tweaking it a little. I want this new column to give me blank spaces when the conditions in two other columns are not met. 

 

I want to create a new column with the "end date" when "finalizado" is "Si" (yes) and when "first end date" has a date if not I want a blank space.

 

If its easier, I could also resolve my problem if some DAX function allowed me to use DISTINCTCOUNT filtering the above conditions.

 

I tried to solve it myself but since "end date" is a custom column I can't do anything in Power Query (where i suppose it would be easy to solve). Since my knowledge of Power Bi is very limited i'm always trying the same few formulas I know without any success...

 

Below I have posted some of the data (from a bigger excel) with a column named "expected result" as an example.

 

As you can see the filters are:

finalizado       first end date    expected result

      SI                 has a date        end date

      SI                   blank               blank

      NO               has a date         blank

      NO                 blank               blank 

 

I would apreciate if somebody could lend me a hand.

 

Thanks a lot!

 

Nº VehículoFinalizadoNº Orden trabajofirst end dateend dateExpected result
R8871TTDNoOT18-0798912/12/2018  
R8871TTDNoOT18-07989   
R0391TTDOT18-0753016/11/201816/11/201816/11/2018
R0391TTDOT18-0753115/11/201816/11/201816/11/2018
R0391TTDOT18-0758916/11/201816/11/201816/11/2018
R6527TTXOT18-0647108/11/201808/11/201808/11/2018
R6527TTXNoOT18-0797308/11/201808/11/2018 
R6527TTXOT18-0711108/11/201808/11/201808/11/2018
R6527TTXOT18-0711106/11/201808/11/201808/11/2018
8718ZGNNoOT18-0797505/11/201805/11/2018 
1803UXGOT18-08027 08/11/2018 
R1415BBRNo 15/11/201805/11/2018 
R1415BBROT18-0247806/11/201806/11/201806/11/2018
3415FBV 07/11/201807/11/201807/11/2018
8718ZGNOT18-02259 05/11/2018 
7341JBMNoOT18-0792221/11/201807/11/2018 
1803UXGOT18-0802708/11/201808/11/201808/11/2018
1803UXGOT18-0802708/11/201808/11/201808/11/2018
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi  @Sorakell,

 

Looking at your data I think it's easier to do it by if has a No or end date is blank return blank.

 

See below the code for DAX and also for M language  (query editor).

 

 

Query Editor (M Language)

if ([Finalizado] = "No" or [first end date] = null) then null else [end date]

================ DAX Expected end date DAX = IF ( Table1[Finalizado] = "NO" || Table1[first end date] = BLANK (); BLANK (); Table1[end date] )

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi  @Sorakell,

 

Looking at your data I think it's easier to do it by if has a No or end date is blank return blank.

 

See below the code for DAX and also for M language  (query editor).

 

 

Query Editor (M Language)

if ([Finalizado] = "No" or [first end date] = null) then null else [end date]

================ DAX Expected end date DAX = IF ( Table1[Finalizado] = "NO" || Table1[first end date] = BLANK (); BLANK (); Table1[end date] )

Regards,

MFelix

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Wow Felix! that formula you gave me worked perfectly! its amazing!. 

 

Now I only have one more step to achieve the final result. I need to concatenate "expected end date" with "nº vehiculo" applying the same filters as before.

 

I want the concatenate result: "nº vehicleexpected end date" only when finished is "yes" and "end date" is not blank.

 

I'm tryingto do it with calculate but I'm not able to do it.

 

Could you give me a hand? 

 

Thanks a lot! you saved me a lot of time...

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.