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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
RuchiSharma
Frequent Visitor

Need to multiply from Previous row result to another column value.

Minimum product : Min(Data[Index])

Min Prod Value=

Data[Base]*CALCULATE((Data[Qty]),FILTER(Data,Data[Index]=MIN(Data[Index])))

"quantity (-) minimum prod value for ex: (10.0*02=0.2)

Need to consider the output of this previous row result (*) qty Ex: (0.2*0.03=0.006)

Formula: 10*0.02=0.2
0.2*0.03=0.006
0.006*0.04=0.00024
0.00024*0.05=0.000012

RuchiSharma_0-1688554622151.png

 

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

Hi @RuchiSharma ,

 

I suggest you to try code as below to create a calculated column.

Output =
VAR _MinProdValue =
    Data[Base]
        * CALCULATE (
            SUM ( Data[Qty] ),
            FILTER ( Data, Data[Index] = MIN ( Data[Index] ) )
        )
RETURN
    IF (
        Data[Index] = MIN ( Data[Index] ),
        _MinProdValue,
        CALCULATE (
            PRODUCT ( Data[Qty] ),
            FILTER ( Data, Data[Index] <= EARLIER ( Data[Index] ) )
        ) * Data[Base]
    )

Result is as below.

vrzhoumsft_0-1688698130377.png

 

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
v-rzhou-msft
Community Support
Community Support

Hi @RuchiSharma ,

 

I suggest you to try code as below to create a calculated column.

Output =
VAR _MinProdValue =
    Data[Base]
        * CALCULATE (
            SUM ( Data[Qty] ),
            FILTER ( Data, Data[Index] = MIN ( Data[Index] ) )
        )
RETURN
    IF (
        Data[Index] = MIN ( Data[Index] ),
        _MinProdValue,
        CALCULATE (
            PRODUCT ( Data[Qty] ),
            FILTER ( Data, Data[Index] <= EARLIER ( Data[Index] ) )
        ) * Data[Base]
    )

Result is as below.

vrzhoumsft_0-1688698130377.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-rzhou-msft  -  What if Index is a date (I think it should work similar since it gives it order) AND also a column with different products (product A, B, C) and this is needed at a per product basis? how would you modify your code to accomodate? 

Thank you so much for spending time on the solution @v-rzhou-msft it's working fine.❤😊

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.