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
Anonymous
Not applicable

Sum with condition

Hi Guys,

 

I have a question for you.

I want to sum a column which has number figure if in the other coloums has a date value.

 

for instance, i have a table like below.

I want to show accumulative line for start and finish. 

 

LineStart

Finish

142020/11/09 
232020/11/102020/12/05
342020/11/112020/12/05
5  
62020/11/092020/12/05
722020/12/05 
5  
22020/12/012020/12/05
352020/12/032020/12/05

 

I tried the code below to get what i want but this one sums up all Line column figures.


Actul IRN date =

VAR _End = CALCULATE ( MAX ( 'SPARES - PO STATUS'[ACTUAL IRN DATE] ), ALL ( 'calendar' ),USERELATIONSHIP('SPARES - PO STATUS'[ACTUAL IRN DATE],'Calendar'[Date]))

RETURN

    IF (

        _End < MIN ( 'calendar'[Date] )|| isblank(MAX ( 'SPARES - PO STATUS'[CDD] )),

        BLANK (),

CALCULATE(

    Sum('SPARES - PO STATUS'[PO_LINE_QUANTITY]), USERELATIONSHIP('SPARES - PO STATUS'[ACTUAL IRN DATE],'calendar'[Date]),

    FILTER(

        ALLSELECTED('calendar'[Date]),

        ('calendar'[Date] <= MAX('calendar'[Date])))))
 
any advices would be appreciated.
 
Regards,
CL
5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you mean that you have four columns in one table?

What is the structure of your table? Could you please provide a mockup sample based on fake data?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you want to calculate the accumulative line like this following screenshots?

 

sum1.jpg

 

If yes, we can create two measures to meet your requirement.

 

Measure = CALCULATE(SUM('Table'[Line]),FILTER('Table','Table'[Start]=MAX('Date'[Date])))+0

 

Measure 2 = 
SUMX(FILTER(ALL('Date'),'Date'[Date]<=MAX('Date'[Date])),[Measure])

 

sum2.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Anonymous
Not applicable

HI @v-zhenbw-msft 

Yes, that's what i want to create.

 

I have 4 date columns to show in a line graph.

But all lines start and end in same dates which is not corret.

do you know how make line start as the date value start and ends?

 

Regards,

CL

Regards,

CL 

amitchandak
Super User
Super User

@Anonymous , refer to if my Blog on HR can help in this case

 https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
AllisonKennedy
Super User
Super User

@Anonymous Sorry, I don't understand what your sample data relates to in the sample formula - there is no reference to [Line], [Start] or [End] columns? Can you provide a sample output of what you want and describe why the formula you have tried/posted does not work?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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