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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mgantt87
New Member

Sum LASTDATE Total Issue

I am having trouble getting my totals to calculate correctly for the example below in which a sum filtering by LASTDATE is used.  I understand the measure is calculating on the total line, so that's why it's producing an undesired result, but I haven't been able to figure out how to make the total correct.

 

In the example below, my page has a filter where filter column = Y (so the 4/30/2024 row for item A is excluded).  The desire is to show the value from the value column for each item where the date is the largest within each item.  So, for A, it should show a value of 3 from the 3/31/2024 record and for B, it should show a value of 4 from the 4/30/2024 record.  The totals row should add these two values together for a total of 7.  The DAX below is working correctly for each row, but the total is showing 4 (which it is picking up from the 4/30/2024 B record).  How can I make this total show 7?


Measure = CALCULATE(SUM('Data'[Value]), LASTDATE('Data'[Date]))

Data:

ItemValueFilter ColumnDate
A1Y1/31/2024
A2Y2/29/2024
A3Y3/31/2024
A3N4/30/2024
B1Y1/31/2024
B2Y2/29/2024
B3Y3/31/2024
B4Y4/30/2024

 

Expected Result:

ItemMeasureLatest Date
A33/31/2024
B44/30/2024
Total7---

 

Current Result:

ItemMeasureLatest Date
A33/31/2024
B44/30/2024
Total4---

 

 

1 ACCEPTED SOLUTION
ExcelMonke
Responsive Resident
Responsive Resident

You may have to use the SUMX function for this.

If you don't have an existing table where your values are equal to your measure, then consider the following:

Measure = 
VAR _SumTable = 
Summarize(
Data[Item],
"Measure",CALCULATE(Data[Value],LASTDATE(Data[Date])
)

RETURN
SUMX(_SumTable,
[Measure]
)

View solution in original post

3 REPLIES 3
ExcelMonke
Responsive Resident
Responsive Resident

You may have to use the SUMX function for this.

If you don't have an existing table where your values are equal to your measure, then consider the following:

Measure = 
VAR _SumTable = 
Summarize(
Data[Item],
"Measure",CALCULATE(Data[Value],LASTDATE(Data[Date])
)

RETURN
SUMX(_SumTable,
[Measure]
)

I stumbled across this after I posted and I think it's basically saying the same thing.  I think I have it working using a similar measure.

Measure Totals, The Final Word - Microsoft Fabric Community

Great!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.