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
praveenjujare
Helper I
Helper I

Need help creating new column

1000074641.png

 Share adjustment price =

 

VAR _INDEX = MAX('Investment'[Index])  

 

VAR _INDEX_1 = _INDEX - 1  

 

VAR a = SUMX('Investment', 'Investment'[Qty])  

 

VAR b = SUMX('Investment', 'Investment'[Price])  

 

VAR c = [Closing Share]  

 

VAR d =

 

    CALCULATE (

 

        [Closing Share],

 

        'Investment'[Index] = _INDEX_1  

 

    )

 

VAR e = (b * a) / c  

 

RETURN

 

    RETURN

 

    SWITCH(

 

        TRUE(),

 

'Investment', 'Investment'[Transaction Type] = "Shares Adjustment", e,

 

        0

 

    )

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @praveenjujare ,

 

Pease try:

Column = 
IF(
    'Investment'[Transaction Type] = "Shares Adjustment",
    VAR PreviousRowPrice = CALCULATE(
        MAX('Investment'[Price]),
        FILTER(
            'Investment',
            'Investment'[Index] = EARLIER('Investment'[Index]) - 1
        )
    )
    VAR PreviousRowClosingShare = CALCULATE(
        MAX('Investment'[Closing Share]),
        FILTER(
            'Investment',
            'Investment'[Index] = EARLIER('Investment'[Index]) - 1
        )
    )
    RETURN
        (PreviousRowPrice * PreviousRowClosingShare) / 'Investment'[Closing Share],
    BLANK()
)

vbofengmsft_0-1731567889000.png

 

Best Regards,

Bof

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @praveenjujare ,

 

Based on the DAX you provided, I’m not able to fully understand the calculation logic for this new column. Could you please describe the calculation logic for this column in words?

 

Best Regards,

Bof

When transaction type = share adjustment then (previous row of price * previous row of closing share )/ present row of closing share

 

Example:   (65.4 * 273000)/2730000

Anonymous
Not applicable

Hi @praveenjujare ,

 

Pease try:

Column = 
IF(
    'Investment'[Transaction Type] = "Shares Adjustment",
    VAR PreviousRowPrice = CALCULATE(
        MAX('Investment'[Price]),
        FILTER(
            'Investment',
            'Investment'[Index] = EARLIER('Investment'[Index]) - 1
        )
    )
    VAR PreviousRowClosingShare = CALCULATE(
        MAX('Investment'[Closing Share]),
        FILTER(
            'Investment',
            'Investment'[Index] = EARLIER('Investment'[Index]) - 1
        )
    )
    RETURN
        (PreviousRowPrice * PreviousRowClosingShare) / 'Investment'[Closing Share],
    BLANK()
)

vbofengmsft_0-1731567889000.png

 

Best Regards,

Bof

 

Thanks sir

123abc
Community Champion
Community Champion

please shere more detail or pbix file.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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