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
Dayna
Helper V
Helper V

Help with incorrect columns totals within a measure

Hello,

 

I have a measure that calculates the value based on whether it's before, or after, the current month, this is then provided as a row total at the bottom.

 

Sales Forecast Quantity (Month) = 

VAR ForecastValue =
    IF (
        MAX ( 'Calendar'[MonthKey] ) < [Today (MonthKey)],
        [Actual Sales (ISS-SO)],
        [Forecast Qty]
    ) + 0
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[MonthKey]  ),
        ForecastValue,
        SUMX ( VALUES ( 'Calendar'[MonthKey] ), ForecastValue )
    )

 

However, my column totals are incorrect, and I think it's due to the MAX in the virtual table.. So here's a sample of my data:

 

Screenshot 2022-06-20 122746.png

 

If we focus on the first row, the total should be 2078320, not 6060000.

 

If I changed the measure to:

Sales Forecast Quantity (Month) = 

VAR ForecastValue =
    IF (
        MAX ( 'Calendar'[MonthKey] ) < [Today (MonthKey)],
        [Actual Sales (ISS-SO)],
        [Forecast Qty]
    ) + 0
RETURN
    IF (
        HASONEVALUE ( 'Calendar'[MonthKey]  ),
        ForecastValue,
        SUMX ( VALUES ('Product'[pt_part]), ForecastValue )
    )

 

Then my row total is still not right (better, but not right):

 

Screenshot 2022-06-20 123041.png

 

Can someone help me, please?

Many thanks,

Dayna

4 REPLIES 4
amitchandak
Super User
Super User

@Dayna , You have the correct fact/transaction table name in place of fact. Try a measure like

 

Sales Forecast Quantity (Month) =

VAR ForecastValue =
IF (
MAX ( 'Calendar'[MonthKey] ) < [Today (MonthKey)],
[Actual Sales (ISS-SO)],
[Forecast Qty]
) + 0
RETURN
SUMX ( summarize (Fact, 'Product'[pt_part], 'Calendar'[MonthKey]), ForecastValue )

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

@amitchandak thanks for the response, a silly question, but how should I set my fact table? I tried Product, which resolves the field for pt_part, but not Calendar as it doesn't have a direct relationship:

Screenshot 2022-06-20 131454.png

Hi @Dayna ,

 

Have your question solved, if yes, please accept it as solution.

 

Power Bi recommend you apply star schema design principals to produce a model comprising dimension and fact tables. Or you can create a new thread about this question.                 

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Hello @v-chenwuz-msft sadly not, as the values are still incorrect.

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.