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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Total is wrong for DIVIDE function

Hello. I am not able to get the total for this formula to accurate total. The column I’m referring to is LostRevYTDSUM. It should be $10,934 and not $7,718. I have shown the detail to the left. I wont be using the ParentPartnerId in my final calculation. It will only be the year and month nbr like on the right. I just included it for detail. I have tried everything. Any suggestions would be appreciated.

MKatsanevas_0-1647620751817.png

LostRevYTDSum =
VAR YTDFiscalMonthNbr = IF(CALCULATE( MAX('Calendar'[fiscal_month_nbr]), 'Calendar'[calendar_date] = TODAY()) = 1, 12,
(CALCULATE( MAX('Calendar'[fiscal_month_nbr]), 'Calendar'[calendar_date] = TODAY()) -1) )

VAR SalesLast24M = CALCULATE(
SUM(ParentPartnerMonthlySales[NetSales]),
CALCULATETABLE (
DATESINPERIOD ('Calendar'[calendar_date], MAX ( PartnerDates[ParentLostCustomerDate] ), -24, MONTH ),
USERELATIONSHIP ( PartnerDates[fiscal_month_end_date] , FiscalMonthEndDate[fiscal_month_end_date] ) ) )

VAR NumOfNonZeroMonths = CALCULATE(
COUNT(ParentPartnerMonthlySales[FiscalMonthEndDate]),
CALCULATETABLE(
DATESINPERIOD('Calendar'[calendar_date], MAX( PartnerDates[ParentLostCustomerDate] ),-24,MONTH),
USERELATIONSHIP( PartnerDates[fiscal_month_end_date], FiscalMonthEndDate[fiscal_month_end_date] ),
NOT(isblank(ParentPartnerMonthlySales[NetSales]))))
 
RETURN
SUMX(
VALUES('Calendar'[fiscal_month_nbr]),
DIVIDE( SalesLast24M, NumOfNonZeroMonths ) * YTDFiscalMonthNbr /-1
)
2 ACCEPTED SOLUTIONS

Try this:

 

LostRevYTDSum =
SUMX (
    VALUES ( ParentPartnerMonthlySales[ParentPartnerID] ),
    [LostRevYTDSumCalc]
)




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

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

I figured it out. Thank you for the suggestion. I just started trying all the columns. 🙂 Appreciate it

MKatsanevas_0-1647889186716.png

 

View solution in original post

8 REPLIES 8
DataInsights
Super User
Super User

@Anonymous,

 

Try splitting the measure into two measures: one measure to do the calculation, and a second measure to calculate totals. The base measure is named "Calc", and the totals measure has the original name. In the totals measure (SUMX), you might need to iterate a column with both fiscal_year_nbr and fiscal_month_nbr (e.g., 202202), instead of just fiscal_month_nbr.

 

LostRevYTDSum Calc =
VAR YTDFiscalMonthNbr =
    IF (
        CALCULATE (
            MAX ( 'Calendar'[fiscal_month_nbr] ),
            'Calendar'[calendar_date] = TODAY ()
        ) = 1,
        12,
        (
            CALCULATE (
                MAX ( 'Calendar'[fiscal_month_nbr] ),
                'Calendar'[calendar_date] = TODAY ()
            ) - 1
        )
    )
VAR SalesLast24M =
    CALCULATE (
        SUM ( ParentPartnerMonthlySales[NetSales] ),
        CALCULATETABLE (
            DATESINPERIOD (
                'Calendar'[calendar_date],
                MAX ( PartnerDates[ParentLostCustomerDate] ),
                -24,
                MONTH
            ),
            USERELATIONSHIP ( PartnerDates[fiscal_month_end_date], FiscalMonthEndDate[fiscal_month_end_date] )
        )
    )
VAR NumOfNonZeroMonths =
    CALCULATE (
        COUNT ( ParentPartnerMonthlySales[FiscalMonthEndDate] ),
        CALCULATETABLE (
            DATESINPERIOD (
                'Calendar'[calendar_date],
                MAX ( PartnerDates[ParentLostCustomerDate] ),
                -24,
                MONTH
            ),
            USERELATIONSHIP ( PartnerDates[fiscal_month_end_date], FiscalMonthEndDate[fiscal_month_end_date] ),
            NOT ( ISBLANK ( ParentPartnerMonthlySales[NetSales] ) )
        )
    )
RETURN
    DIVIDE ( SalesLast24M, NumOfNonZeroMonths ) * YTDFiscalMonthNbr / -1

 

LostRevYTDSum =
SUMX ( VALUES ( 'Calendar'[fiscal_month_nbr] ), [LostRevYTDSum Calc] )

 





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

Proud to be a Super User!




Anonymous
Not applicable

I tried using UNION. The total is closer but it shoudl be $10,934.

MKatsanevas_0-1647874941784.png

 

Try this:

 

LostRevYTDSum =
SUMX (
    VALUES ( ParentPartnerMonthlySales[ParentPartnerID] ),
    [LostRevYTDSumCalc]
)




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

Proud to be a Super User!




Anonymous
Not applicable

That gets me nothing.

MKatsanevas_0-1647876227939.png

 

I would need to see your data model. Be sure to remove sensitive data before uploading the pbix. You can use one of the file services such as OneDrive and post the link here.





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

Proud to be a Super User!




Anonymous
Not applicable

I figured it out. Thank you for the suggestion. I just started trying all the columns. 🙂 Appreciate it

MKatsanevas_0-1647889186716.png

 

Anonymous
Not applicable

unfortunately its connected to a server. Not sure how Id recreate it.

Anonymous
Not applicable

I tried your suggestion but I still cant get the right total. One issue is that the dates are fiscal and the Fiscal_year_month_name is a text. we dont have a year and month in the numeric. VALUES only takes one column. I even tried just using the calendar table name only. Same result. Any other thoughts?

MKatsanevas_0-1647873865521.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.