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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Si_7777
Advocate I
Advocate I

DAX Help count weeks over forecast

Wonder if anyone can help.

 

I made a graph of sales vs fc vs stretch (stretch being above fc).  I have written a measure to colour code bars according to over fc or over stretch value.  I thought it be nice to have a card stating X week count over FC, how would I achieve this?

 

Si_7777_0-1754057719901.png

 

1 ACCEPTED SOLUTION
johnbasha33
Super User
Super User

Hi @Si_7777  

ou can create a DAX measure to count the number of weeks where actual sales exceeded forecast (FC), and display that in a Card visual.

Option A: If your dataset is at week level

Weeks Over FC =
COUNTROWS(
FILTER(
VALUES(Sales[Week]),
CALCULATE(SUM(Sales[Actual])) > CALCULATE(SUM(Sales[Forecast]))
)
)

Option B: If your dataset is at daily level, group by week:

Weeks Over FC =
COUNTROWS(
FILTER(
SUMMARIZE('Date', 'Date'[Week Start], "ActualSales", CALCULATE(SUM(Sales[Actual])), "ForecastSales", CALCULATE(SUM(Sales[Forecast]))),
[ActualSales] > [ForecastSales]
)
)

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




View solution in original post

4 REPLIES 4
v-saisrao-msft
Community Support
Community Support

Hi @Si_7777,

Have you had a chance to review the solution we shared by @rohit1991 @johnbasha33 ? If the issue persists, feel free to reply so we can help further.

 

Thank you.

rohit1991
Super User
Super User

Hi @Si_7777

 

Yes, you can create a DAX measure to count the number of weeks where actual sales exceeded forecast values, and display it in a card visual. Assuming your dataset has a Week column and columns for Actual sales and Forecast Sales, you can use the following measure:

Weeks Over Forecast = CALCULATE(COUNTROWS(VALUES('SalesData'[Week])), FILTER(VALUES('SalesData'[Week]), CALCULATE(SUM('SalesData'[Actual Sales])) > CALCULATE(SUM('SalesData'[Forecast Sales]))))

This measure works by evaluating each unique week and counting only those where the total actual sales are greater than forecasted sales. It handles filter context correctly, works with slicers, and avoids issues caused by repeated weeks or row-by-row comparison making it a reliable solution for weekly-level reporting.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
johnbasha33
Super User
Super User

Hi @Si_7777  

ou can create a DAX measure to count the number of weeks where actual sales exceeded forecast (FC), and display that in a Card visual.

Option A: If your dataset is at week level

Weeks Over FC =
COUNTROWS(
FILTER(
VALUES(Sales[Week]),
CALCULATE(SUM(Sales[Actual])) > CALCULATE(SUM(Sales[Forecast]))
)
)

Option B: If your dataset is at daily level, group by week:

Weeks Over FC =
COUNTROWS(
FILTER(
SUMMARIZE('Date', 'Date'[Week Start], "ActualSales", CALCULATE(SUM(Sales[Actual])), "ForecastSales", CALCULATE(SUM(Sales[Forecast]))),
[ActualSales] > [ForecastSales]
)
)

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




Thank you, I wasnt using summerize.  I have date table by day, sales fact, and forecast fact all joining by each day date.  Option B worked for me.

 

Is there a way to see the result that summerize would produce (The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.)  Just to aid my understanding of that function.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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