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
Frajzerr
New Member

Today() in a measure

Hello,

 

I have one fact table with about 1,2M rows and a few dim tables, basic star schema. In powerBi canvas I created simple table including a few columns from dim tables and a measure counting rows number in the fact table.

And I found strange behaviour within different measure :

Measure:=

DATEDIFF(

SELECTEDVALUE(

'dimtable'[date]

),

TODAY(),

DAY

)

I don't know why but using TODAY() makes visual performance dramatically slow. For an example I used only TODAY() as a measure and I received an error with lack of memory , I checked it again but I reduced numbers of columns in visual and then it worked but It gave me results of all possible connections between data from dim tables from which I took columns. 

 

I am trying to undestand this behavour as it is strange to me, and the same for some static value:

 

ExampleMeasure:=

5

 

Adding above measure to any table visual even with really small dataset is extemely slow... why ?

 

But my final question is how can I add today as part of my measure to make it work efficiently.

 

Thanks in advance !

3 REPLIES 3
Frajzerr
New Member

Unfortunately both solutions don't work 😕

 

I am sure that today() causing it cause below measure works immediately

Measure:=

MAX('dimtable'[date])

 

but

 

Measure:=
Var  T = TODAY()
Return

DATEDIFF(

MAX('dimtable'[date]),

 T ,

DAY

)

engine is not even able to calculate it... Instead of today() I tried even DATE(2022,11,09) and still the same. It doesn't matter whether these function are closed in variables or not. 

 

 

VahidDM
Super User
Super User

Hi @Frajzerr 

 

Try to keep TODAY() as a variable and test that measure performance again:
I'm not sure about your model and visual but you can change the SELECTEDVALUE to MAX

Measure:=
Var _T = TODAY()
Return

DATEDIFF(

MAX('dimtable'[date]),

 _T ,

DAY

)

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

 

amitchandak
Super User
Super User

@Frajzerr , Try like 

Measure:=

DATEDIFF(
maxx(allselected('dimtable'), 'dimtable'[date])
TODAY(),
DAY

)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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