cancel
Showing results for
Did you mean:
Frequent Visitor

## SUM DAX Query on condition

I have a table with shipment number and dates. Need to calculate the Total backlog of that shipment and consider the latest date value and sum the column.

 Shipment Date Backlog Result(required) AX 28/10/2022 28000 0 AX 29/10/2022 0 0 BX 28/10/2022 1400 0 BX 29/10/2022 0 0
7 REPLIES 7
Community Support

Hi @insandur ,

Does that make sense? If so, kindly mark my answer as the solution to close the case please. If it does not , please share your ways. Thanks in advance.

Best Regards

Community Support Team _ Polly

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

Community Support

Hi @insandur ,

I have created a simple sample, please refer to it to see if it helps you.

Create 2 measures.

``````Measure =
CALCULATE (
SUM ( 'Table'[Backlog] ),
FILTER (
ALL ( 'Table' ),
'Table'[Shipment] = SELECTEDVALUE ( 'Table'[Shipment] )
)
)
``````
``````Measure2 =
VAR _maxdate =
MAXX ( ALL ( 'Table' ), 'Table'[Date] )
RETURN
CALCULATE (
SUM ( 'Table'[Backlog] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] = _maxdate )
)
``````

Best Regards

Community Support Team _ Polly

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

Frequent Visitor

Hi Polly,

Thanks for the solution, Backlog in my table is actually a meausre not a column so i am not able to get the correct ans.

Community Support

Hi @insandur ,

I have modified the answer. Please refer to it to see if it helps you.

``Measure = SUMX(FILTER(ALL('Table'),'Table'[Shipment]=SELECTEDVALUE('Table'[Shipment])),[Mbacklog])``
``````Measure2 =
VAR _maxdate =
MAXX ( ALL ( 'Table' ), 'Table'[Date] )
RETURN
SUMX(
FILTER ( ALL ( 'Table' ), 'Table'[Date] = _maxdate )
,[Mbacklog])
``````

The [Mbacklog] is also a measure.

Best Regards

Community Support Team _ Polly

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

Frequent Visitor

Thanks again, But i dont get the desired ans😐  Please see the screenshots

Community Support

Hi @insandur ,

There is nothing error with the measure. In my pbix file, it works well. How the [Backlog2] calculates? Could you please provide your pbix file without privacy information for us testing?

Best Regards

Community Support Team _ Polly

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

Community Champion

@insandur Edit the question and add a column for the desired result with detailed explanation.

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors