Forum Discussion
Measure to count a value from different tables with differing date relationships (pls read)
Hi D_PBI
Here’s a single DAX measure that will switch between your four calculations based on the slicer selection and correctly honor whichever Date→Agreement relationship (Execution vs Received) or period comparison you need:
Dynamic Metric =
VAR Selected = SELECTEDVALUE( 'Measure Selector'[MeasureName], "Funding Applications" )
VAR BaseFilter =
agreement[Agreement Type] = 100000024 &&
(
CONTAINSSTRING( agreement[Agreement Status], "Preliminary" ) ||
CONTAINSSTRING( agreement[Agreement Status], "Full Application" ) ||
CONTAINSSTRING( agreement[Agreement Status], "Submitted" )
)
RETURN
SWITCH(
TRUE(),
Selected = "Funding Applications",
CALCULATE(
DISTINCTCOUNT( agreement[agreementid] ),
USERELATIONSHIP( 'Date'[Date], agreement[Execution Date] ),
BaseFilter
),
Selected = "Patent Applications",
CALCULATE(
DISTINCTCOUNT( agreement[agreementid] ),
USERELATIONSHIP( 'Date'[Date], agreement[Received Date] ),
BaseFilter
),
Selected = "Potential Value",
CALCULATE(
SUM( agreement[Value] ),
USERELATIONSHIP( 'Date'[Date], agreement[Execution Date] ),
BaseFilter
),
Selected = "Potential Value (Prev Year)",
CALCULATE(
SUM( agreement[Value] ),
TREATAS(
SAMEPERIODLASTYEAR( VALUES( 'Date'[Date] ) ),
agreement[Execution Date]
),
BaseFilter
),
BLANK()
)
Place this single measure in your matrix, use the Date hierarchy for rows (Year→Quarter→Month) and the disconnected Measure Selector slicer to drive the value shown.
- USERELATIONSHIP activates the inactive relationship on‐the‐fly
- TREATAS( SAMEPERIODLASTYEAR(...) ) lets you show last-year values against your current context
- SELECTEDVALUE picks the user’s measure choice from the slicer
This one‐measure approach scales as you add or remove measure names—no new DAX objects are needed.
If the above information helps you, please give us a Kudos and marked the Accept as a solution.
Best Regards,
Community Support Team _ C Srikanth.