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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
mmh
Helper I
Helper I

Each record of date from start and end_date by Dax

Hi,

There is a fact table with contract date as starDate and EndDate as

IdinvestmentResidualValue start_dateEnd_date
21100501/1/202104/06/23
22300601/1/20221/1/2023

 

Need to calculated Exposure for every day inbetween (star and endate). For this measure i have created a custom colum for each record (in between start and end date), but problem the table become huge for each record n taking long time load. So is there any way create each record of date in Dax or measure exposure from date dimension. the calculation (exposure is )= remaining days of contract /total duration * (investment-residual value). Where total duratio is just subtraction of end_date and start_date and Remining days is contact is substraction of each_date (that would like create as calculate column or measures in Dax ) and start_date.

 

Thanks in advance.

BR

mmh

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Exposure =
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Exposure =
    CALCULATE (
        SUMX (
            'Table',
            VAR StartDate = 'Table'[start date]
            VAR EndDate = 'Table'[end date]
            VAR Investment = 'Table'[investment]
            VAR ResidualValue = 'Table'[residual value]
            VAR TotalDuration =
                INT ( EndDate - StartDate )
            VAR RemainingDays =
                INT ( EndDate - MaxDate )
            RETURN
                DIVIDE ( RemainingDays, TotalDuration ) * ( Investment - ResidualValue )
        ),
        'Table'[start date] <= MaxDate
            && 'Table'[End date] >= MaxDate
    )
RETURN
    Exposure

View solution in original post

2 REPLIES 2
mmh
Helper I
Helper I

Hi John,

Thanks. It worked exactly as per my expectation

johnt75
Super User
Super User

Try

Exposure =
VAR MaxDate =
    MAX ( 'Date'[Date] )
VAR Exposure =
    CALCULATE (
        SUMX (
            'Table',
            VAR StartDate = 'Table'[start date]
            VAR EndDate = 'Table'[end date]
            VAR Investment = 'Table'[investment]
            VAR ResidualValue = 'Table'[residual value]
            VAR TotalDuration =
                INT ( EndDate - StartDate )
            VAR RemainingDays =
                INT ( EndDate - MaxDate )
            RETURN
                DIVIDE ( RemainingDays, TotalDuration ) * ( Investment - ResidualValue )
        ),
        'Table'[start date] <= MaxDate
            && 'Table'[End date] >= MaxDate
    )
RETURN
    Exposure

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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