Forum Discussion
Count showing wrong compare to bar chart
- 4 months ago
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 axisRETURN
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
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!
Thanks in advance.