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

Count Number of Days from Selected year to Last update

Hi

I am looking for a solution to count the number of days since the last update date. I have a slicer for years (2020, 2021, 2022, etc.), and when I select the year , I need to calculate the number of days from the last date of the selected year to the last update by Team.

See the sample

ajisharavind_99_1-1690188210090.png

 

1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hi @ajisharavind_99,

Let's assume you have such a calendar table not connected to the main one:

barritown_0-1690223588261.png

Having that table, you could create such a measure:

barritown_1-1690223689055.png

In plain text for convenience:

Diff Measure = 
VAR LastUpdate = MIN ( [Last Update] )
VAR MaxDate = MAX ( 'Date'[Date] )
RETURN DATEDIFF ( LastUpdate, MaxDate, DAY ) 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

 

View solution in original post

3 REPLIES 3
v-binbinyu-msft
Community Support
Community Support

Hi @ajisharavind_99 ,

There is an another solution for you, different with @barritown , need not create a large date table.

1. below is my test table

Table:

vbinbinyumsft_2-1690341121144.png

Year:

vbinbinyumsft_3-1690341138457.png

 

2. create ameasure with below dax formula

Measure =
VAR _year =
    SELECTEDVALUE ( 'Year'[Year] )
VAR _date =
    DATE ( _year, 12, 31 )
VAR lu =
    SELECTEDVALUE ( 'Table'[Last Update] )
RETURN
    IF ( ISFILTERED ( 'Year'[Year] ), ABS ( DATEDIFF ( lu, _date, DAY ) ), "" )

3. add a slicer with Year field, add a table visual with Table fields and measure

Animation17.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

barritown
Super User
Super User

Hi @ajisharavind_99,

Let's assume you have such a calendar table not connected to the main one:

barritown_0-1690223588261.png

Having that table, you could create such a measure:

barritown_1-1690223689055.png

In plain text for convenience:

Diff Measure = 
VAR LastUpdate = MIN ( [Last Update] )
VAR MaxDate = MAX ( 'Date'[Date] )
RETURN DATEDIFF ( LastUpdate, MaxDate, DAY ) 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

 

@barritown @v-binbinyu-msft I appreciate your prompt reply. You made my day, and both were successful.

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.