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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Analitika
Post Prodigy
Post Prodigy

How calculate quantity according to last date in table in Power BI

Hi, I am having table with calculating quantity based on last date in table. 

Analitika_0-1674468238556.png

Analitika_1-1674468275589.png

According to this example I should get 1, because last date is 2022-08-26, and at first line quantity is 1. Unfortunately,

I am getting all sum of column - 32, when I expected 1.  My measure:

kiekis_test1 = 
var __LastDate = LASTDATE(op_detales[Dokumento data])
RETURN
CALCULATE(
   CALCULATE(sum(op_detales[qty_in]), FILTER(op_detales,op_detales[Dokumento data]=[_m_date_A]&& op_detales[modul]="Pirkimai"))
   
)

So how to fix my measure?

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Analitika 

is seems your VAR is not in use. try like:

kiekis_test1 =
var __LastDate = LASTDATE(op_detales[Dokumento data])
RETURN
CALCULATE(
    sum(op_detales[qty_in]), 
    FILTER(
        op_detales,
        op_detales[Dokumento data]=__LastDate
             && op_detales[modul]="Pirkimai"
    )
)

I tried but getting null result:

Analitika_0-1674470380866.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors