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

View all the Fabric Data Days sessions on demand. View schedule

Reply
praveenjujare
Helper I
Helper I

creating new measure or column ratio_1

Need help to get output as shown in the below table where ratio is measure i need help to create ratio_1 

 

DateInvestment Company NameTransaction TypeRatioRatio_1
31-12-2022 00:00testPurchase 1
31-01-2023 00:00testFV adjustment 1
28-02-2023 00:00testFV adjustment 1
31-03-2023 00:00testFV adjustment 1
30-04-2023 00:00testFV adjustment 1
30-04-2023 00:00testSales 1
31-05-2023 00:00testFV adjustment 1
15-06-2023 00:00testShares Adjustment1010
30-06-2023 00:00testFV adjustment 10
18-07-2023 00:00testSales 10
19-07-2023 00:00testSales 10
20-07-2023 00:00testSales 10
23-07-2023 00:00testSales 10
24-07-2023 00:00testSales 10
25-07-2023 00:00testSales 10
27-07-2023 00:00testSales 10
04-09-2023 00:00testSales 10
05-09-2023 00:00testSales 10
28-09-2023 00:00testSales 10
30-09-2023 00:00testShares Adjustment55
31-10-2023 00:00testFV adjustment 5
02-11-2023 00:00testSales 5
06-11-2023 00:00testSales 5
30-11-2023 00:00testFV adjustment 5
14-12-2023 00:00testSales 5
18-12-2023 00:00testSales 5
20-12-2023 00:00testSales 5
24-12-2023 00:00testSales 5
25-12-2023 00:00testSales 5
3 ACCEPTED SOLUTIONS
Angith_Nair
Continued Contributor
Continued Contributor

Hi @praveenjujare 

Could you please elaborate the requirement along with the calculation?

View solution in original post

Hi @praveenjujare 

Try the below dax for Ratio_1

Ratio_1 = 
VAR CurrentDate = TableName[Date]
VAR LastAdjustmentDate = 
    CALCULATE(
        MAX(TableName[Date]),
        FILTER(
            TableName,
            TableName[Transaction Type] = "Shares Adjustment" &&
            TableName[Date] <= CurrentDate
        )
    )
VAR LastRatio = 
    CALCULATE(
        MAX(TableName[Ratio]),
        FILTER(
            TableName,
            TableName[Transaction Type] = "Shares Adjustment" &&
            TableName[Date] = LastAdjustmentDate
        )
    )
RETURN
    IF(
        NOT ISBLANK(LastAdjustmentDate),
        LastRatio,
        BLANK()
    )

View solution in original post

Kedar_Pande
Super User
Super User

@praveenjujare 

Create a calculated column in Power BI:

Ratio_1 = 
VAR CurrentDate = 'Table'[Date]
VAR LastSharesAdjustmentDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Date] <= CurrentDate &&
'Table'[Transaction Type] = "Shares Adjustment"
)
)
VAR LastRatio =
CALCULATE(
MAX('Table'[Ratio]),
FILTER(
'Table',
'Table'[Date] = LastSharesAdjustmentDate
)
)
RETURN
IF(
ISBLANK('Table'[Ratio]),
LastRatio,
'Table'[Ratio]
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

View solution in original post

8 REPLIES 8
Kedar_Pande
Super User
Super User

@praveenjujare 

Create a calculated column in Power BI:

Ratio_1 = 
VAR CurrentDate = 'Table'[Date]
VAR LastSharesAdjustmentDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Date] <= CurrentDate &&
'Table'[Transaction Type] = "Shares Adjustment"
)
)
VAR LastRatio =
CALCULATE(
MAX('Table'[Ratio]),
FILTER(
'Table',
'Table'[Date] = LastSharesAdjustmentDate
)
)
RETURN
IF(
ISBLANK('Table'[Ratio]),
LastRatio,
'Table'[Ratio]
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

thanks for help

Angith_Nair
Continued Contributor
Continued Contributor

Hi @praveenjujare 

Could you please elaborate the requirement along with the calculation?

For every row after a "Shares Adjustment", ratio_1 will keep the last ratio until the next "Shares Adjustment" occurs, at which point it updates the value of ratio_1.

Hi @praveenjujare 

Try the below dax for Ratio_1

Ratio_1 = 
VAR CurrentDate = TableName[Date]
VAR LastAdjustmentDate = 
    CALCULATE(
        MAX(TableName[Date]),
        FILTER(
            TableName,
            TableName[Transaction Type] = "Shares Adjustment" &&
            TableName[Date] <= CurrentDate
        )
    )
VAR LastRatio = 
    CALCULATE(
        MAX(TableName[Ratio]),
        FILTER(
            TableName,
            TableName[Transaction Type] = "Shares Adjustment" &&
            TableName[Date] = LastAdjustmentDate
        )
    )
RETURN
    IF(
        NOT ISBLANK(LastAdjustmentDate),
        LastRatio,
        BLANK()
    )

thanks for help 

Bibiano_Geraldo
Super User
Super User

Hi @praveenjujare , can you be more clear? What ratio_1 calculate? what are conditions?

Ratio_1 =
VAR _INDEX = 'Investment'[Index]  -- Current row index
VAR _LASTNOTSHARESADJUSTMENT =
    CALCULATE (
        MAX ( 'Investment'[Index] ),
        FILTER (
            'Investment',
            'Investment'[Transaction Type] <> "Shares Adjustment"  -- Exclude Shares Adjustment
            && 'Investment'[Index] <= _INDEX
        )
    )
   

VAR _LASTRATIOAFTERSHARESADJUSTMENT =
    CALCULATE (
        [Ratio],
        FILTER ( 'Investment', 'Investment'[Index] = _LASTNOTSHARESADJUSTMENT )
    )

-- If this row is a Shares Adjustment, return the current Ratio, else return the last valid Ratio
RETURN
    SWITCH(
        TRUE(),
        'Investment'[Transaction Type] = "Shares Adjustment", [Ratio],  
        _LASTRATIOAFTERSHARESADJUSTMENT  
    )
 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors