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
sdb_utd
Frequent Visitor

Sum all earliest values by field

Hi,

 

I have an invoice table which contains a company name, a sale vaue and a date. There's also a filter column which users will toggle on the report.

 

I'm trying to get a few figures:

1. Difference between earliest and latest price per for each name. I have this as a measure called "Difference"

2. The overall percent change from first to last for all names. This should be -12.46%, and should be just sum of the Difference measure, but sum will not accept a measure. Any ideas?

 

Raw data example

NameValueFilterDate
United250y01/01/2020
MPC90y01/01/2020
SDB150y01/01/2020
FPL70n01/01/2020
CHEM80y01/01/2020
United50y02/01/2020
United80y03/01/2020
MPC1000y02/01/2020
MPC100y03/01/2020
MPC45n04/01/2020
SDB100y02/01/2020
SDB200y03/01/2020
FPL100y02/01/2020
FPL65y03/01/2020
CHEM500y02/01/2020
CHEM85y03/01/2020
United225y04/03/2020

 

Report example

NameFirstValueLastValueTotal Name values

Total all values

Percent total spendDifference%GT Difference
FPL706523531907.37-7.14%-3.23%
SDB150200450319014.1133.33%15.05%
United250225605319018.97-10.00%-4.52%
CHEM8085665319020.856.25%2.82%
MPC90451235319038.71-50.00%-22.58%
3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @sdb_utd,

Can you please provide your measure formula for test? If will help to test and modify your formula on sample data.

How to Get Your Question Answered Quickly  

In addition, you can also take a look at the following blog about measure total issue:

Measure Totals, The Final Word  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

https://www.dropbox.com/s/ddvxc6y9psou0du/sample%20data.pbix?dl=0

 

I think I have this working now. My previous measure for summing the earliest and latest values was just summing the values at the earliest or latest date in the table, ie. summing all values for 01/01/2020 or all values for 04/03/2020, rather than the latest value for a name.

Sum of Total  at Latest Date = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        'Table',
        'Table'[Name]  = ( 'Table'[Name] )
        &&
        'Table'[Date]  = CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table','Table'[Name]))
           )
)
amitchandak
Super User
Super User

@sdb_utd ,

I did not get your last column. Rest of the cal is in file.https://www.dropbox.com/s/xc9lp45fx76j1do/FirstLastvalue.pbix?dl=0

 

I have used firstnonblankvalue and lastnonblankvalue, those are part of lastest release

 

Appreciate your Kudos.

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.