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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anuj_1196
Frequent Visitor

Expiry Balance calculation based on expiry date.

NameExpiry DateBalance
A1/12/202310
A1/12/202420
A1/12/20255
B1/12/202340
B1/12/202450
C1/12/202360
C1/12/202470
C1/12/2025 
D1/12/202490
D1/12/2025100
D1/12/2026110


Desired Output:

NameExpiry DateBalance
A1/12/20255
B1/12/202450
C1/12/202470
D1/12/2026110
1 ACCEPTED SOLUTION

Hi @Anuj_1196 ,

 

You can create measures and show your result in a table visual.

Last Expire Date = 
MAXX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Balance] <> BLANK ()
            && 'Table'[Name] = MAX ( 'Table'[Name] )
    ),
    'Table'[Expiry Date]
)
Balance on Last Expire Date =
CALCULATE (
    SUM ( 'Table'[Balance] ),
    FILTER ( 'Table', 'Table'[Expiry Date] = [Last Expire Date] )
)

Result is as below.

vrzhoumsft_0-1685433705122.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

5 REPLIES 5
FreemanZ
Super User
Super User

or you plot a table visual with the name column and two measures like:

ExpiryDate = MAX(data[Expiry Date])
_Balance = 
MAXX(
    FILTER(
        data,
        data[Expiry Date]=[ExpiryDate]
    ),
    data[Balance]
)

it worked like:

FreemanZ_2-1684995324984.png

Thanks for your time. I'm using similar formula, unfortunately it's giving me the sum rather than the balance on that particular year.

 

Hi @Anuj_1196 ,

 

You can create measures and show your result in a table visual.

Last Expire Date = 
MAXX (
    FILTER (
        ALL ( 'Table' ),
        'Table'[Balance] <> BLANK ()
            && 'Table'[Name] = MAX ( 'Table'[Name] )
    ),
    'Table'[Expiry Date]
)
Balance on Last Expire Date =
CALCULATE (
    SUM ( 'Table'[Balance] ),
    FILTER ( 'Table', 'Table'[Expiry Date] = [Last Expire Date] )
)

Result is as below.

vrzhoumsft_0-1685433705122.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.

Hi Rico,

I really appreciate your help in solving this puzzle. 

"You are the best"

FreemanZ
Super User
Super User

hi @Anuj_1196 

try to create a calculated table like:

Table = 
ADDCOLUMNS(
    ADDCOLUMNS(
        VALUES(data[Name]),
        "Expiry Date",
        CALCULATE(MAX(data[Expiry Date]))   
    ),
    "Balance",
    CALCULATE(MAX(data[Balance]))
)

it worked like:

FreemanZ_1-1684994862744.png

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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