Forum Discussion
powerbi desktop
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Base Date(a calculated table):
Base Date = DISTINCT('Table'[Date])
Compare Date(a calculated table):
Compare Date = DISTINCT('Table'[Date])
You may create three measures as below.
Count of Dimensions = COUNTROWS('Table')
Net variance =
IF(
HASONEVALUE('Base Date'[Date])&&HASONEVALUE('Compare Date'[Date]),
COUNTROWS(
FILTER(
'Table',
[Date]=SELECTEDVALUE('Compare Date'[Date])
)
)-
COUNTROWS(
FILTER(
'Table',
[Date]=SELECTEDVALUE('Base Date'[Date])
)
)
)
Actual varaince =
var _comparetab =
CALCULATETABLE(
DISTINCT('Table'[Dimension]),
FILTER(
ALL('Table'),
'Table'[Date]=SELECTEDVALUE('Compare Date'[Date])
)
)
var _basetab =
CALCULATETABLE(
DISTINCT('Table'[Dimension]),
FILTER(
ALL('Table'),
'Table'[Date]=SELECTEDVALUE('Base Date'[Date])
)
)
var _result =
COUNTROWS(
FILTER(
_comparetab,
NOT([Dimension] in _basetab)
)
)
return
IF(
HASONEVALUE('Base Date'[Date])&&HASONEVALUE('Compare Date'[Date]),
IF(
ISBLANK(_result),
0,
_result
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is the requirement
- v-alq-msft6 years ago
Community Support
Hi, Anonymous
Based on your requirement, I have modified the data as below. The pbix file is attached in the end.
Base Date(a calculated table):
Base Date = DISTINCT('Table'[Date])Compare Date(a calculated table):
Compare Date = DISTINCT('Table'[Date])You may modify the measure as below.
Actual varaince = var _comparetab = CALCULATETABLE( DISTINCT('Table'[Dimension]), FILTER( ALL('Table'), 'Table'[Date]=SELECTEDVALUE('Compare Date'[Date]) ) ) var _basetab = CALCULATETABLE( DISTINCT('Table'[Dimension]), FILTER( ALL('Table'), 'Table'[Date]=SELECTEDVALUE('Base Date'[Date]) ) ) var _result = COUNTROWS( FILTER( _basetab, NOT([Dimension] in _comparetab) ) ) return IF( HASONEVALUE('Base Date'[Date])&&HASONEVALUE('Compare Date'[Date]), IF( ISBLANK(_result), 0, _result ) )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Hi, count is coming right but I need to variance per employee but data is poping for every employee .
- Anonymous6 years agoNot applicable
I have also replaced the country of A(india ) to A(USA) on 06/01/19