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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Calculate the sum of specifit rows

I have following table:

 

 SalesCOGSProfit
January1000500500
February1000500500
March20005001500
April30005002500
May40005003500
June50005004500
July60005005500
August600010005000
September600010005000
October600010005000
November600010005000
December600010005000

 

Now i want to create

1. a new measure of sum of profit from March to December forecast.

2. Another measure of sum of profit from January to February as an actual value.

 

Then put these two new measure together in a line chart to see the actual and forecast together.

 

I am bit lost about how to do this, could anyon please help? Thank you in advance 🙂

1 ACCEPTED SOLUTION
helassal
Resolver II
Resolver II

@Anonymous ,

 

Hi there,

 

You can write the measures like that:

 

m_ActualProfit = if( min('Table'[Month]) in {"January","February"}, CALCULATE(SUM('Table'[Profit])))

m_ForecastProfit = if( NOT(MIN('Table'[Month]) IN {"January","February"}), CALCULATE(SUM('Table'[Profit])))

 

And then display them in  a chart like that:

 

ActualForecast.png

 

BUT, I would like to suggest few enhancements to the way you are shaping the data in your data model, here are some pointers:

1- Try to use an actual date instead of the month name, the reason for that is that it makes it easier to do the following:

     a- Write dynamic date filters instead of static ones, for example the m_ActualProfit could then be written like that:

m_ActualProfit = if( MIN('Table'[MonthAsDate]) < DATE(YEAR(NOW()),MONTH(NOW()),1), CALCULATE(SUM('Table'[Profit])))

    b- To be able to get the months sorted correctly in the chart instead of having to explicitly add a Month No column and use it to sort Month name.

2- You can even go a bit further and create a date dimension in your data model if you are going to build more complex reporting based on that data model.

   Refs:

        https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns

        https://docs.microsoft.com/en-us/power-bi/desktop-date-tables

        https://docs.microsoft.com/en-us/power-bi/desktop-auto-date-time

 

Hope this helps.

 

Best Regards,

Haitham

View solution in original post

1 REPLY 1
helassal
Resolver II
Resolver II

@Anonymous ,

 

Hi there,

 

You can write the measures like that:

 

m_ActualProfit = if( min('Table'[Month]) in {"January","February"}, CALCULATE(SUM('Table'[Profit])))

m_ForecastProfit = if( NOT(MIN('Table'[Month]) IN {"January","February"}), CALCULATE(SUM('Table'[Profit])))

 

And then display them in  a chart like that:

 

ActualForecast.png

 

BUT, I would like to suggest few enhancements to the way you are shaping the data in your data model, here are some pointers:

1- Try to use an actual date instead of the month name, the reason for that is that it makes it easier to do the following:

     a- Write dynamic date filters instead of static ones, for example the m_ActualProfit could then be written like that:

m_ActualProfit = if( MIN('Table'[MonthAsDate]) < DATE(YEAR(NOW()),MONTH(NOW()),1), CALCULATE(SUM('Table'[Profit])))

    b- To be able to get the months sorted correctly in the chart instead of having to explicitly add a Month No column and use it to sort Month name.

2- You can even go a bit further and create a date dimension in your data model if you are going to build more complex reporting based on that data model.

   Refs:

        https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns

        https://docs.microsoft.com/en-us/power-bi/desktop-date-tables

        https://docs.microsoft.com/en-us/power-bi/desktop-auto-date-time

 

Hope this helps.

 

Best Regards,

Haitham

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.