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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
apohl1
Helper II
Helper II

How to create a measure that applies context and sums correctly in Power BI?

Hi everyone,

 

I'm working with a table similar to the one below and facing a challenge in creating a measure for the last column ("Forecasted Q2"). The goal is to calculate this value based on the Product class for each product.

 

The main challenge is that the measure needs to:

  • Take the context of the Product class into account when calculating each row.
  • Still aggregate correctly in the total row, so the sum at the bottom reflects the sum of individual forecasted values, not just a simple total of the sales.

Could anyone suggest how to write such a measure in Power BI that respects the row context but also calculates the total sum accurately?

 

Thanks in advance!

 

Product codeProduct classSales Q1Forecast approach Q2Forecasted Q2
Product AFocus100Q1 + 10%110
Product BFocus10Q1 + 10%11
Product CFocus30Q1 + 10%33
Product DNot focus50Q150
Total 190 204

 

1 ACCEPTED SOLUTION
v-ssriganesh
Community Support
Community Support

Hello @apohl1,
Thank you for reaching out to the Microsoft Fabric Community Forum.

I’ve reproduced your scenario in Power BI Desktop based on the table structure and logic you shared and I was able to get the expected output, where:

  • The forecast calculation is based on the Product class (e.g. “Focus” adds 10%)
  • The total row correctly reflects the sum of individual forecasted values (not a bulk calculation)

I created:

  • A SalesTable with your product, class, and Q1 sales values.
  • A ForecastTable with each Product class and its corresponding forecast factor.
  • A relationship between SalesTable[Product class] and ForecastTable[Product class] with: Cardinality: Many-to-One (*:1) and Direction: Single

Here’s the DAX measure I used to calculate Forecasted Q2:

Forecasted Q2 =

SUMX (

    SalesTable,

    SalesTable[Sales Q1] * RELATED(ForecastTable[Forecast Factor])

)

For your reference and testing, I’m attaching the .pbix file.

vssriganesh_0-1754646370417.png

 

Best regards,
Ganesh Singamshetty.

View solution in original post

5 REPLIES 5
v-ssriganesh
Community Support
Community Support

Hello @apohl1,

Hope everything’s going great with you. Just checking in has the issue been resolved or are you still running into problems? Sharing an update can really help others facing the same thing.

Thank you.

v-ssriganesh
Community Support
Community Support

Hello @apohl1,
Thank you for reaching out to the Microsoft Fabric Community Forum.

I’ve reproduced your scenario in Power BI Desktop based on the table structure and logic you shared and I was able to get the expected output, where:

  • The forecast calculation is based on the Product class (e.g. “Focus” adds 10%)
  • The total row correctly reflects the sum of individual forecasted values (not a bulk calculation)

I created:

  • A SalesTable with your product, class, and Q1 sales values.
  • A ForecastTable with each Product class and its corresponding forecast factor.
  • A relationship between SalesTable[Product class] and ForecastTable[Product class] with: Cardinality: Many-to-One (*:1) and Direction: Single

Here’s the DAX measure I used to calculate Forecasted Q2:

Forecasted Q2 =

SUMX (

    SalesTable,

    SalesTable[Sales Q1] * RELATED(ForecastTable[Forecast Factor])

)

For your reference and testing, I’m attaching the .pbix file.

vssriganesh_0-1754646370417.png

 

Best regards,
Ganesh Singamshetty.

Thank you! Your solution would have worked if I was able to setup a relationship between the two tables. Unfortunately, my model is more complex and it's not possible. Howerver, I managed to get to the results I wanted with the following formula: 

 
Forecasted Q2 = CALCULATE(Salestable[Sales]*1.05,filter(Producttable,[Product class]="Focus"))+CALCULATE(Salestable[Sales],filter('Producttable,[Product class]="Non-Focus"))
apohl1
Helper II
Helper II

Thank you! Sorry I should have clarified that "Forecast factor" and "Sales" are stored in two different tables. Therefore, this solution doesn't work. 

DataInsights
Super User
Super User

@apohl1,

 

I created a column [Forecast factor Q2] with the amount to multiply by Sales Q1.

 

Measure:

 

Forecasted Q2 = 
SUMX ( Table1, Table1[Sales Q1] * Table1[Forecast factor Q2] )

 

DataInsights_0-1754604520700.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.