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

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

Reply
Analitika
Post Prodigy
Post Prodigy

Sum values in column by condition in Power Bi

Hi,

 

I have columns in table, quantity and date. I need to calculate sum values based on last date of that object. For example:

First column quantity, second -  date

Analitika_1-1674458248723.png

 

 

Analitika_0-1674458219145.png

Based on this example, result must be 1. But I am getting 32, it is wrong. My measure:

kiekis_test1 = 
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?

21 REPLIES 21
Mikelytics
Resident Rockstar
Resident Rockstar

HI @Analitika 

 

This is really a normal measure filter.

 

1 Idea) What happens if you take all thgese filters out. Can you please to that?

 

2 Idea) Please creat a normal SUM Meausre and filter on the 26/8/2022

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!
Thennarasu_R
Responsive Resident
Responsive Resident

Hi @Analitika 
Try this Measure

 

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

 

Thanks ,
Thennarasu 

Analitika_0-1674459840980.png

Result is empty.

Mikelytics
Resident Rockstar
Resident Rockstar

Hi @Analitika 

 

Can you please try:

 

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")
)

 

Can you please show the results in a visual if it does not work? By that I can better see how you use the measure.

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Now I am getting null result like this:

Analitika_0-1674459508913.png

 

Are there any filters applied to the visual? Can you maybe provide sample data?

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Nope, I don't see filters

only for testig. What happens when you take out the second gilter in your measure?

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

 

or if you use it like this

kiekis_test1 = 
var __LastDate = LASTDATE(op_detales[Dokumento data])
RETURN
CALCULATE(
   sum(op_detales[qty_in]),
   op_detales[Dokumento data]=__LastDate
)

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

It gives me 0 all time.

@Analitika 

Can you also please show the pop-up which comes when you click here?

Mikelytics_0-1674460542336.png

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Analitika_0-1674461167757.png

 

@Analitika you see, there are filters on the visual. Are you 100% sure that these filters do not filter out the data you want to see?

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 
 
------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Analitika_0-1674462670965.png

 

Yeah I am sure. 

Analitika_0-1674461646773.png

 

 

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

 

 Analitika_1-1674461806556.png

Zero values, seems filtering in measure not working.

 

Because without filtering it sums all values.

hm @Analitika 

 

Can you try:

kiekis_test1 = 

CALCULATE(
   sum(op_detales[qty_in]),
   LASTDATE(op_detales[Dokumento data])
)

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Yeah I am  getting 0

Okay, since the data is coming but the value is zero it ahst  to be one fo these filters

Mikelytics_0-1674463506116.png

Beacuse you measure identifies the right data but the result is zero. This means there further criteria which filter out further rows. It has to be one of those.

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

I checked that not affects calculations, I think filter in measure not works well.

HI @Analitika 

This is really a normal measure filter Can you please try the following twpo options.

 

1) Take out all the filter on the visual and look for the result

2) Create a normal SUM measure and filter on the date which you got from last date

 

Can you please tell what happens?

 

Best regards
Michael
-----------------------------------------------------
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Appreciate your thumbs up!
@ me in replies or I'll lose your thread.

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Filtering works well with other columns, with date it doesn't work. So seems problem is with date.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.