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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Generating an Index based on date and account?

Hi there,

Please see the below snapshot. I am trying to create an index based on the account and the date, as you can see the first account becomes active on 1/1/20 goes forward while the second account becomes active on 2/1/20,  i want to solve for the desired output where i am multiplying the amount * the appropriate rate and running it down.

 

I have been able to generate this individually, meaning one table for each account, but when i try to do it on one table the calculation falls apart. Can anyone provide insight on how to solve this?  I was thinking an index of some sort but wasn't sure?

IndexSolution.PNG

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

Hi @Anonymous ,

 

I have created a sample for your reference, we can create the calculated columns to work on it.

Index = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        'Table'[Account] = EARLIER ( 'Table'[Account] )
            && 'Table'[date] <= EARLIER ( 'Table'[date] )
    )
)
Am = 
var a = 'Table'[Index]
return
IF('Table'[Amount]=BLANK(),CALCULATE(MAX('Table'[Amount]),FILTER('Table','Table'[Index]<a && 'Table'[Account] = EARLIER('Table'[Account]))),'Table'[Amount])
Future Value = 
VAR ind = 'Table'[Index]
RETURN
    'Table'[Am]
        * CALCULATE (
            PRODUCTX ( 'Table', 1 - 'Table'[Rate] ),
            FILTER (
                'Table',
                'Table'[Index] <= ind
                    && 'Table'[Account] = EARLIER ( 'Table'[Account] )
            )
        )

Capture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

I have created a sample for your reference, we can create the calculated columns to work on it.

Index = 
CALCULATE (
    COUNTROWS ( 'Table' ),
    FILTER (
        'Table',
        'Table'[Account] = EARLIER ( 'Table'[Account] )
            && 'Table'[date] <= EARLIER ( 'Table'[date] )
    )
)
Am = 
var a = 'Table'[Index]
return
IF('Table'[Amount]=BLANK(),CALCULATE(MAX('Table'[Amount]),FILTER('Table','Table'[Index]<a && 'Table'[Account] = EARLIER('Table'[Account]))),'Table'[Amount])
Future Value = 
VAR ind = 'Table'[Index]
RETURN
    'Table'[Am]
        * CALCULATE (
            PRODUCTX ( 'Table', 1 - 'Table'[Rate] ),
            FILTER (
                'Table',
                'Table'[Index] <= ind
                    && 'Table'[Account] = EARLIER ( 'Table'[Account] )
            )
        )

Capture.PNG

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Wow this is amazing!  Thank you!

Anonymous
Not applicable

Any help on this team?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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