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

Table Vs Query

I'm sure you will be able to tell from my questions that I can a complete newbie. Thanks in advance for your patience.

 

I'm working with an excel spreadsheet and I have a column called Next Assessment Date which includes some dates and some blanks. Some dates are in the past and some are in the future. When I look at the table in PBI, the Next Assessment Date column in blank. When I look at the query, the same column has dates values and "null" appropriately.

 

I would like to add a new column. The values in the new column would be calculated based on a formula like this: 

Column = if(isblank([Next Assessment Date]),0,datediff([Next Assessment Date],today(),day)).. which produces an error: start date cannot be greater than the end date.

 

My questions are:

 

Why do I only see date values and "null" in Next Assessment Date column in the query (as opposed to the table)?

Should I add the column to the table or the query? Why?

1 ACCEPTED SOLUTION

I figured it out. Thanks for the help!

View solution in original post

7 REPLIES 7
v-yulgu-msft
Employee
Employee

Hi @ckennedy,

 

As you said, "Some dates are in the past and some are in the future.", and the start date cannot be greater than the end date when you use DATDIFF function. 

 

So, please try this:

Column =
IF (
    ISBLANK ( [Next Assessment Date] ),
    0,
    IF (
        Table3[Next Assessment Date] < TODAY (),
        DATEDIFF ( [Next Assessment Date], TODAY (), DAY ),
        DATEDIFF ( TODAY (), [Next Assessment Date], DAY )
    )
)

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Yuliana. This got rid of the error in my new column I'm calling [Days Since NAD].

 

Now, the [Next Assessment Date] column is completely blank. I see date values in the query, but not the table. What would cause an entire column to be blank? I'm assuming this is why [Days Since NAD] (using the new formula) has all zeros.

Hi @ckennedy,

 

What do you mean "Query" and "Table"? You said the [Next Assessment Date] column is completely blank, was this column an original field in source data or a calculated column? Can you post a screenshot to show the result you got?

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Sorry, I wasn't very clear.

 

When I go to the table, [Next Assessment Date]  has no values in the column. When I edit the query, the [Next Assessment Date] column has "null" or date values as I would expect.

 

I'm wondering why values are missing in the table.

 

TABLE

 

table.png

 

QUERY

Query Editor.png

Hi @ckennedy,

 

Do you mean there isn't any data in [Next Assessment Date]  in Table view? 

 

The row order is not the same in TABLE and QUERY. If there is a large number of data records in table, please sroll down o check whether all rows are empty. Please check whether below highlighted records exists in TABLE.

1.PNG

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I figured it out. Thanks for the help!

Anonymous
Not applicable

@ckennedy,

The syntax for DATEDIFF is DATEDIFF(<start_date>, <end_date>, <interval>). Since you have some dates in the past and future, the error is produced. 

For Next Assessment, can you provide your sample PBIX file? 

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.

Top Solution Authors