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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Yumikang
Helper II
Helper II

Why does my VAR function return other values for newly created columns?

Dear all,

I need help,Why does my VAR function return other values for newly created columns?

I would like to create new columns about entry times as shown in the green box.

Find the latest entry time before the current line, if this time and the entry time difference of 2min, then return to the earlier one; if the difference is more than 2min and there is no earlier time, then return to the entry time of the current line.

But why is it that there in the red box, I'm returning a new never-before-seen time?

Yumikang_0-1732781313270.png

This is the DAX function for my new column:

entry time new = VAR _last=maxx(FILTER('RPMsheet','RPMsheet'[entry time]<EARLIER('RPMsheet'[entry time])),'RPMsheet'[entry time])
return if(ISBLANK(_last),'RPMsheet'[entry time],if(DATEDIFF(_last,'RPMsheet'[entry time],SECOND)<=120,_last,'RPMsheet'[entry time]))
1 ACCEPTED SOLUTION

pls try this and add the similar coding in red in your original DAX.

 

Column =
VAR _last=maxx(FILTER('Table','Table'[number]=EARLIER('Table'[number])&&'Table'[entry time]<EARLIER('Table'[entry time])),'Table'[entry time])
return if (ISBLANK(_last),'Table'[entry time],_last)
 
11.PNG




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

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

@Yumikang 

it looks like your DAX is correct. Have you tried sort by the entry time column to see if there is the time which is 11:04:28?

 

11.PNG





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

Proud to be a Super User!




Oh thank you,My original sheet looked like this.

Yumikang_1-1732783907481.png

 

I found a time of 11:04:28

But I find that it shouldn't be calculated that way.

The VAR function calculation just mentioned should be performed only when the green module “number” column  is the same.
Otherwise it will match the time of the other “number”.
How can I change the previous function?

 

Dear all,

I need help,Why does my VAR function return other values for newly created columns?

I would like to create new columns about entry times as shown in the green box.

Find the latest entry time before the current line, if this time and the entry time difference of 2min, then return to the earlier one; if the difference is more than 2min and there is no earlier time, then return to the entry time of the current line.

But why is it that there in the red box, I'm returning a new never-before-seen time?

Yumikang_0-1732782508463.png

 

 

Hi, @Yumikang ,

 

The image is not visible. please share a better one. also share a sample dataset and desired output for better understanding for the problem.



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

pls try this and add the similar coding in red in your original DAX.

 

Column =
VAR _last=maxx(FILTER('Table','Table'[number]=EARLIER('Table'[number])&&'Table'[entry time]<EARLIER('Table'[entry time])),'Table'[entry time])
return if (ISBLANK(_last),'Table'[entry time],_last)
 
11.PNG




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

Proud to be a Super User!




thank you ,i have solved it.

you are welcome





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

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors