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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Need help with date function

Hi all

 

Below is a simple table.

I want to calculate the AMOUNT_LEFT with a formula.

In the (explanation) field I have mentioned how the formula looks like.

 

The mutation_dates must be ranked (first date on top)

 

Can somebody help me out, thanks!

John

 

bottle_nrcapacity_bottle_in_kgmutation_dateamount_usedamount_left(explanation)
8448125-2-201811112-1=11
84481226-2-20184711-4=7
1 ACCEPTED SOLUTION
AkhilAshok
Solution Sage
Solution Sage

Create a calculated column like below:

 

amount_left =
VAR CurrentBottleNumber = 'Table'[bottle_nr]
VAR CurrentMutationDate = 'Table'[mutation_date]
VAR CurrentBottleCapacity = 'Table'[capacity_bottle_in_kg]
VAR UsedTableFilter =
    FILTER (
        'Table',
        'Table'[bottle_nr] = CurrentBottleNumber
            && 'Table'[mutation_date] <= CurrentMutationDate
    )
VAR UsedBottleCapcity =
    CALCULATE ( SUM ( 'Table'[amount_used] ), UsedTableFilter )
RETURN
    CurrentBottleCapacity - UsedBottleCapcity

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

 

I am assuming you want to write a measure so that you obtain a dynamic solution for changes made in slicers/filters.  Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AkhilAshok
Solution Sage
Solution Sage

Create a calculated column like below:

 

amount_left =
VAR CurrentBottleNumber = 'Table'[bottle_nr]
VAR CurrentMutationDate = 'Table'[mutation_date]
VAR CurrentBottleCapacity = 'Table'[capacity_bottle_in_kg]
VAR UsedTableFilter =
    FILTER (
        'Table',
        'Table'[bottle_nr] = CurrentBottleNumber
            && 'Table'[mutation_date] <= CurrentMutationDate
    )
VAR UsedBottleCapcity =
    CALCULATE ( SUM ( 'Table'[amount_used] ), UsedTableFilter )
RETURN
    CurrentBottleCapacity - UsedBottleCapcity
Anonymous
Not applicable

Its working, thanks a lot!

 

John

aravind9652
New Member

@Anonymous

 

that means.... Do you want display recent transacation... ? 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.