cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

Regular Visitor

## Expiry Balance calculation based on expiry date.

 Name Expiry Date Balance A 1/12/2023 10 A 1/12/2024 20 A 1/12/2025 5 B 1/12/2023 40 B 1/12/2024 50 C 1/12/2023 60 C 1/12/2024 70 C 1/12/2025 D 1/12/2024 90 D 1/12/2025 100 D 1/12/2026 110

Desired Output:

 Name Expiry Date Balance A 1/12/2025 5 B 1/12/2024 50 C 1/12/2024 70 D 1/12/2026 110
1 ACCEPTED SOLUTION
Community Support

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.

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.

5 REPLIES 5
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:

Regular Visitor

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

Community Support

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.

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.

Regular Visitor

Hi Rico,

I really appreciate your help in solving this puzzle.

"You are the best"

Super User

try to create a calculated table like:

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

it worked like:

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors