cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
jayPBI23
Helper I
Helper I

Calculate percentage based on two dates duration and today's date

I have two dates: 

 

policy start date: 1/1/2023   

policy end date:  1/20/2023

Duration: 20 days 

todays date: 1/10/2023 (this date will change daily)

 

For policy start and end dates 1/1/2023 - 1/20/2023 (20 Days). If looking ar report on 1/10/2023, the duration of the policy 1/1/2023 - 1/10/2023 (10 days) is at 50%. 

 

If looking at the report on 1/11/2023, the duration will be 1/1/2023 - 1/11/2023 (11 days), which will be 55%. 

 

So this number will change every day depending on when you look at the report. 

 

I want the duration column to be shown in percentage. How would I write this?

 

Thanks,

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @jayPBI23 ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR start_date =
    DATE ( 2023, 1, 1 )
VAR end_date =
    DATE ( 2023, 1, 20 )
VAR cur_date =
    TODAY ()
VAR _diff1 =
    DATEDIFF ( start_date, end_date, DAY )
VAR _diff2 =
    DATEDIFF ( start_date, cur_date, DAY )
RETURN
    DIVIDE ( _diff2, _diff1 )

2. add a crad visual with this measure

vbinbinyumsft_0-1673403064290.png

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.

View solution in original post

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @jayPBI23 ,

Please try below steps:

1. create a measure with below dax formula

Measure =
VAR start_date =
    DATE ( 2023, 1, 1 )
VAR end_date =
    DATE ( 2023, 1, 20 )
VAR cur_date =
    TODAY ()
VAR _diff1 =
    DATEDIFF ( start_date, end_date, DAY )
VAR _diff2 =
    DATEDIFF ( start_date, cur_date, DAY )
RETURN
    DIVIDE ( _diff2, _diff1 )

2. add a crad visual with this measure

vbinbinyumsft_0-1673403064290.png

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.

Hey thanks for the reply. What if  today's date (cur_date) is coming from a date filter. Is there a way to dynamically change that as the user chnages the date filter?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors