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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
BalajiBuddha
Frequent Visitor

Count showing wrong compare to bar chart

Hi Everyone,

I want to sum upp all bar chart visuals and give the total but here it is giving last month total in table thats not correct pelase correct the measure and give me

BalajiBuddha_0-1775745808581.png

 



Quantity by Owner and Snapshot Date =

VAR AutomationSelected =

    CONTAINS (

        VALUES ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type] ),

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type],

        "Automation"

    )

 

/*  Month context coming from Calendar axis */

VAR MonthStart =

    DATE (

        YEAR ( MAX ( 'CALENDAR'[Date] ) ),

        MONTH ( MAX ( 'CALENDAR'[Date] ) ),

        1

    )

 

VAR MonthEnd =

    EOMONTH ( MonthStart, 0 )

 

/*  Latest snapshot WITHIN the month on the axis */

VAR SnapshotDateSelected =

    CALCULATE (

        MAX ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] ),

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] >= MonthStart,

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] <= MonthEnd

    )

 

/*  Potential Close Date window: snapshot month → +11 months */

VAR CloseDateEnd =

    EOMONTH ( MonthStart, 11 )

 

RETURN

IF (

    ISBLANK ( SnapshotDateSelected ),

    BLANK (),

    CALCULATE (

 

        /*  Same aggregation logic that gives correct totals */

        SUMX (

            SUMMARIZE (

                OPEN_OPPORTUNITY_EVOLUTION_C4C,

                OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Key],

                OPEN_OPPORTUNITY_EVOLUTION_C4C[Sales Cycle Phase],

                "Qty_Clean",

                    SUM ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Quantity] )

            ),

            [Qty_Clean]

        ),

 

        /*  Lock to snapshot of the CURRENT month */

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date]

            = SnapshotDateSelected,

 

        /*  Potential Close Date range */

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] >= MonthStart,

        OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] <= CloseDateEnd,

 

        /*  Conditional Automation logic */

        FILTER (

            'PRODUCT_STRUCTURE_C4C',

            NOT AutomationSelected

                ||

                NOT (

                    'PRODUCT_STRUCTURE_C4C'[Model] IN {

                        "Automation Analysis",

                        "Project",

                        "Peripherals",

                        "Change Request",

                        "LSI",

                        "Software",

                        "System Support"

                    }

                )

        )

    )

)

1 ACCEPTED SOLUTION
pankajnamekar25
Super User
Super User

Hello @BalajiBuddha 

 

try this 

 

Quantity by Owner and Snapshot Date =
VAR AutomationSelected =
CONTAINS (
VALUES ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type],
"Automation"
)

/* Detect if we are in a single-month row or in a total/subtotal row */
VAR IsMonthLevel =
HASONEVALUE ( 'CALENDAR'[Month] ) -- swap to [YearMonth] or whichever
-- column drives your axis

RETURN
IF (
IsMonthLevel,

/* ── SINGLE MONTH ROW ── same logic as before */
VAR MonthStart =
DATE ( YEAR ( MAX ( 'CALENDAR'[Date] ) ), MONTH ( MAX ( 'CALENDAR'[Date] ) ), 1 )
VAR MonthEnd = EOMONTH ( MonthStart, 0 )
VAR SnapshotDateSelected =
CALCULATE (
MAX ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] <= MonthEnd
)
VAR CloseDateEnd = EOMONTH ( MonthStart, 11 )
RETURN
IF (
ISBLANK ( SnapshotDateSelected ),
BLANK (),
CALCULATE (
SUMX (
SUMMARIZE (
OPEN_OPPORTUNITY_EVOLUTION_C4C,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Key],
OPEN_OPPORTUNITY_EVOLUTION_C4C[Sales Cycle Phase],
"Qty_Clean", SUM ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Quantity] )
),
[Qty_Clean]
),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] = SnapshotDateSelected,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] <= CloseDateEnd,
FILTER (
'PRODUCT_STRUCTURE_C4C',
NOT AutomationSelected
|| NOT ( 'PRODUCT_STRUCTURE_C4C'[Model] IN {
"Automation Analysis", "Project", "Peripherals",
"Change Request", "LSI", "Software", "System Support"
} )
)
)
),

/* ── TOTAL / SUBTOTAL ROW ──
Iterate each distinct month visible in the current filter context
and SUM the per-month results so the total = sum of bar chart values */
SUMX (
VALUES ( 'CALENDAR'[Month] ), -- same column as IsMonthLevel check above
VAR MonthStart =
DATE ( YEAR ( MIN ( 'CALENDAR'[Date] ) ), MONTH ( MIN ( 'CALENDAR'[Date] ) ), 1 )
VAR MonthEnd = EOMONTH ( MonthStart, 0 )
VAR SnapshotDateSelected =
CALCULATE (
MAX ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] <= MonthEnd
)
VAR CloseDateEnd = EOMONTH ( MonthStart, 11 )
RETURN
IF (
ISBLANK ( SnapshotDateSelected ),
0,
CALCULATE (
SUMX (
SUMMARIZE (
OPEN_OPPORTUNITY_EVOLUTION_C4C,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Key],
OPEN_OPPORTUNITY_EVOLUTION_C4C[Sales Cycle Phase],
"Qty_Clean", SUM ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Quantity] )
),
[Qty_Clean]
),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] = SnapshotDateSelected,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] <= CloseDateEnd,
FILTER (
'PRODUCT_STRUCTURE_C4C',
NOT AutomationSelected
|| NOT ( 'PRODUCT_STRUCTURE_C4C'[Model] IN {
"Automation Analysis", "Project", "Peripherals",
"Change Request", "LSI", "Software", "System Support"
} )
)
)
)
)
)

 

 

 

 

if possible share pbix

 

 


If my response helped you, please consider clicking
Accept as Solution and giving it a Like 👍 – it helps others in the community too.

Thanks,

Connect with me on:
LinkedIn |
Data With Pankaj - YouTube

View solution in original post

5 REPLIES 5
v-nmadadi-msft
Community Support
Community Support

Hi @BalajiBuddha 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Please show the expected outcome based on the sample data you provided.

Regards

mussaenda
Super User
Super User

Hi @BalajiBuddha ,

 

Are you using the same measure for both visuals?

Yes iam using same measures in both

pankajnamekar25
Super User
Super User

Hello @BalajiBuddha 

 

try this 

 

Quantity by Owner and Snapshot Date =
VAR AutomationSelected =
CONTAINS (
VALUES ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Type],
"Automation"
)

/* Detect if we are in a single-month row or in a total/subtotal row */
VAR IsMonthLevel =
HASONEVALUE ( 'CALENDAR'[Month] ) -- swap to [YearMonth] or whichever
-- column drives your axis

RETURN
IF (
IsMonthLevel,

/* ── SINGLE MONTH ROW ── same logic as before */
VAR MonthStart =
DATE ( YEAR ( MAX ( 'CALENDAR'[Date] ) ), MONTH ( MAX ( 'CALENDAR'[Date] ) ), 1 )
VAR MonthEnd = EOMONTH ( MonthStart, 0 )
VAR SnapshotDateSelected =
CALCULATE (
MAX ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] <= MonthEnd
)
VAR CloseDateEnd = EOMONTH ( MonthStart, 11 )
RETURN
IF (
ISBLANK ( SnapshotDateSelected ),
BLANK (),
CALCULATE (
SUMX (
SUMMARIZE (
OPEN_OPPORTUNITY_EVOLUTION_C4C,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Key],
OPEN_OPPORTUNITY_EVOLUTION_C4C[Sales Cycle Phase],
"Qty_Clean", SUM ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Quantity] )
),
[Qty_Clean]
),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] = SnapshotDateSelected,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] <= CloseDateEnd,
FILTER (
'PRODUCT_STRUCTURE_C4C',
NOT AutomationSelected
|| NOT ( 'PRODUCT_STRUCTURE_C4C'[Model] IN {
"Automation Analysis", "Project", "Peripherals",
"Change Request", "LSI", "Software", "System Support"
} )
)
)
),

/* ── TOTAL / SUBTOTAL ROW ──
Iterate each distinct month visible in the current filter context
and SUM the per-month results so the total = sum of bar chart values */
SUMX (
VALUES ( 'CALENDAR'[Month] ), -- same column as IsMonthLevel check above
VAR MonthStart =
DATE ( YEAR ( MIN ( 'CALENDAR'[Date] ) ), MONTH ( MIN ( 'CALENDAR'[Date] ) ), 1 )
VAR MonthEnd = EOMONTH ( MonthStart, 0 )
VAR SnapshotDateSelected =
CALCULATE (
MAX ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] ),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] <= MonthEnd
)
VAR CloseDateEnd = EOMONTH ( MonthStart, 11 )
RETURN
IF (
ISBLANK ( SnapshotDateSelected ),
0,
CALCULATE (
SUMX (
SUMMARIZE (
OPEN_OPPORTUNITY_EVOLUTION_C4C,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Opportunity Key],
OPEN_OPPORTUNITY_EVOLUTION_C4C[Sales Cycle Phase],
"Qty_Clean", SUM ( OPEN_OPPORTUNITY_EVOLUTION_C4C[Quantity] )
),
[Qty_Clean]
),
OPEN_OPPORTUNITY_EVOLUTION_C4C[Snapshot Date] = SnapshotDateSelected,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] >= MonthStart,
OPEN_OPPORTUNITY_EVOLUTION_C4C[Potential Close Date] <= CloseDateEnd,
FILTER (
'PRODUCT_STRUCTURE_C4C',
NOT AutomationSelected
|| NOT ( 'PRODUCT_STRUCTURE_C4C'[Model] IN {
"Automation Analysis", "Project", "Peripherals",
"Change Request", "LSI", "Software", "System Support"
} )
)
)
)
)
)

 

 

 

 

if possible share pbix

 

 


If my response helped you, please consider clicking
Accept as Solution and giving it a Like 👍 – it helps others in the community too.

Thanks,

Connect with me on:
LinkedIn |
Data With Pankaj - YouTube

Hi Pankaj,

it is not showing selected months total values in table showing 0, i want to show total values in table, please see below screenshot!

BalajiBuddha_0-1775793355352.png

 

Thanks in advance.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.