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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
insandur
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.

 

ShipmentDateBacklog          Result(required)                 
AX28/10/2022280000
AX29/10/202200
BX28/10/202214000
BX29/10/202200
7 REPLIES 7
v-rongtiep-msft
Community Support
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.

v-rongtiep-msft
Community Support
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 )
    )

vpollymsft_0-1667529703266.png

 

If I have misunderstood your meaning, please provide more details with your desired output.

 

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.

 

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.

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.

vpollymsft_0-1667538446734.png

 

 

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.

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

 

insandur_1-1667540037972.pnginsandur_2-1667540057132.png

 

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.

AntrikshSharma
Community Champion
Community Champion

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors