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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply

Calculated column is not returning the desired value using Calculate

Hello all.

 

I have two tables, equipment and snapshot. equipment has all assets, snapshot report on some issues with assets. snapshot has a date column called run_date, where the snapshot of the state of the assets was captured. equipment has a column called equipment_start_up_date, when the equipment was registered. both alos share a column called plant_key

 

Now, I want to create a calculated column in snapshot to capture how many new assets were created 30 days before the snapshot was captured. I created this:

 

Column =

Calculate(
    countrows(equipment),
    Filter(
        all(equipment),
        equipment[equipment_start_up_date] >= DATEADD(snapshot[run_date],-1,MONTH) &&
        equipment[equipment_start_up_date] <= snapshot[run_date] &&
        equipment[plant_key] = snapshot[plant_key]
    )
  )
 
However, it´s not returning the data I need, it's returning a number geater than the one it should.
 
 
 
Thanks for taking a look.
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

30 days or one month?  There's a difference...

 

lbendlin_0-1712434984675.png

 

View solution in original post

DATEADD applies to the entire column.  To shift individual dates you use EDATE.

View solution in original post

7 REPLIES 7

@lbendlin I'm puzzled as to why I don't get the same result as you. In my dataset, both tables are related to a plant dimension and a date dimension, and plant key is a calculated column in snapshot. Finally, equipment has over 1,7 million rows.

 

Could any of this thing affect the outcome? 

 

for example, for Dec 4, 2023, TC11BLO, you are getting 347 rows, which is the right amount. However, I get 0:

 

 

 

 

 

I'm seeing the filter is not taking into account the period of dates provided, only the specific day for that row, so it must find a perfect coincidence in plant and date to return anything.

 

Any idea? 

 

Thanks again.

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

I understand full data may be required, but I'm restricted to share it. I ended up creating a measure, based on your ideas and the measure is working fine for my purposes, so this is good enough. Again, realy thnakful for the effort.

got it, thanks!

lbendlin
Super User
Super User

30 days or one month?  There's a difference...

 

lbendlin_0-1712434984675.png

 

@lbendlin , 1 month is the right thing, you are right.

 

This solves it beautifully. Thank you very much.

 

If it was not too much to ask, would you mind to clarify why my implementation gave a wrong calculation?

 

Again, thanks for your time and help.

DATEADD applies to the entire column.  To shift individual dates you use EDATE.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.