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
trovisco
Helper I
Helper I

Query Editor - Fill a Cell Value with the Min of a Column Value of another Table

Hello Everyone,

I would Like to fill a Cell Value in My query Table with the MIN Value of a Column of another Table, as shown below..

Img1.jpg

 

 

 

 

 

 

 

 

 

 

 

 

This is the Source Table where I want to get the Value from:Img2.jpg

 

1. Is this Possible to do directly in the Query Editor? 

At the moment I am doing it outside the Query Editor, by adding a Calculated Column with a Formula, but it would be much better if it was done directly in Query Editor

Img3.jpg

 

 

 

 

 

My Final Objective is to then be able to plot in the same Chart the Hours by Date, but I don't have a common Date Column for both data... Please see the images below:

img5.jpg

img4.jpg

 

 

 

 

 

 

 

 

2. What would be a good solution to have a same common date axis for both Data?

 

I hope it was everything Clear,

Thanks for your support in Advance!

1 ACCEPTED SOLUTION

Hi @trovisco ,

 

Looking at your file the issue is because of the way you have refered to the table.

 

In M Language when you have non continuous naming (wiht a space on it) you need to have the following syntax:

#"Name Discontinued"

 

the # is an operator that determines the variable name in this case the table name within the "". So basically in your syntax that is what is missing if you use the following code it will work properly based on the test of the file you have send out to me.

 

if [Data Inicial]= null then List.Min(#"Event Duration Prediction"[Date]) else [Data Inicial]

 

No need to use the Date.FromText syntax has you had also on your calculation.


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

8 REPLIES 8
MFelix
Super User
Super User

Hi @trovisco ,

 

Add a custom column to your first table with the following syntax:

 

if [Input Milestones Dates]= null then List.Min("Report SAP DAB"[Date Created])else [Input Milestones Dates]

Then delete the Input Milestones Dates and rename the new column to Input Milestones Dates

 

To have a common axis you need to create a calendar table and relate them with both tables.


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



Hello Miguel! Thanks for the quick reply!

 

I impletemented the code you've mentioned, but I am getting the following error:

unn.jpgAny Idea how to solve it? 

Thank you in advance!

Hi @trovisco ,

 

Check if the Date Created is a text or a Date field, you need to have it as a date field.


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



I have checked and it is formated as Date 😞

 

Any other ideas?

 

fff.jpg

Hi  @trovisco ,

 

Try the following:

 

if [Input Milestones Dates]= null then Date.FromText(List.Min("Report SAP DAB"[Date Created]))else [Input Milestones Dates]

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



Hi @MFelix , 

Unfortunately it is still returning an error. I've sent you the PBI file. 

Hi @trovisco ,

 

Looking at your file the issue is because of the way you have refered to the table.

 

In M Language when you have non continuous naming (wiht a space on it) you need to have the following syntax:

#"Name Discontinued"

 

the # is an operator that determines the variable name in this case the table name within the "". So basically in your syntax that is what is missing if you use the following code it will work properly based on the test of the file you have send out to me.

 

if [Data Inicial]= null then List.Min(#"Event Duration Prediction"[Date]) else [Data Inicial]

 

No need to use the Date.FromText syntax has you had also on your calculation.


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



It works now 🙂 Thanks

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.