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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
7ea8ea
Helper III
Helper III

Measure that calculates the latest value every time source is updated

Hi all,

 

I have a data set that looks something like this:

GroupValueDate
A81/12/20
B91/12/20
A61/1/20
B81/1/20

 

I would like to create two measures that give the latest value as the output for each group. For example, in this case, I would like the measure to output 6 for group A, and 8 for group B. I am working with live data. Therefore, data will be updated every month to include the month's group and value. For example, when it is February, 2 new rows will appear with their own unique values. I would like to just pull out the latest values only. Any help would be appreciated. Thanks

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

Hi, @7ea8ea 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create two measures as below.

Result A = 
var maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    FILTER(
        ALL('Table'),
        [Group]="A"
    )
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALL('Table'),
        [Group]="A"&&
        [Date]=maxdate
    )
)
Result B = 
var maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    FILTER(
        ALL('Table'),
        [Group]="B"
    )
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALL('Table'),
        [Group]="B"&&
        [Date]=maxdate
    )
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @7ea8ea 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

b1.png

 

You may create two measures as below.

Result A = 
var maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    FILTER(
        ALL('Table'),
        [Group]="A"
    )
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALL('Table'),
        [Group]="A"&&
        [Date]=maxdate
    )
)
Result B = 
var maxdate = 
CALCULATE(
    MAX('Table'[Date]),
    FILTER(
        ALL('Table'),
        [Group]="B"
    )
)
return
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        ALL('Table'),
        [Group]="B"&&
        [Date]=maxdate
    )
)

 

Result:

b2.png

 

Best Regards

Allan

 

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

amitchandak
Super User
Super User

@7ea8ea , I think the date should be 1/1/21 . Otherwise 1/12/20 is max (in mm/dd/yyyy) format. I have that.

 

The attached file should work with the correct date or date format. Please find the file after the signature.

 

In case you need two measures

 

calculate(max(Table[Value]), filter(Table, Table[Date] = calculate(Min(Table[Date]), allexcept(Table, Table[Group]))) , Table[group] = "A")


calculate(max(Table[Value]), filter(Table, Table[Date] = calculate(Min(Table[Date]), allexcept(Table, Table[Group]))) , Table[group] = "B")

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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