Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Community!
I have 2 fact tables Actual and Scenario ( weekly snapshot data for last 4 weeks) and dimention table which filter Scenario table, need to find ID from Actual table which are not present in selected scenario data and calculate amount for these records. I know that correct way to do this is via virtual table but have troubles how to get filtered Scenario table dynamically. Data model you can see below:
First I've tried to create virtual table with except but is not dynamical
__NewTest =
var _vAct = SELECTCOLUMNS( Data, "ID", Data[ID])
var _vSc = SELECTCOLUMNS( ScenarioData, "ID", ScenarioData[ID])
var _vNew = EXCEPT( _vAct, _vSc)
return
ADDCOLUMNS(
_vNew, "Amount", CALCULATE( SUM( Data[Amount]))
)
Than I went with calculatetable but selectedvalue or switch is not getting neded ID
except =
var _vSelecedScenario = SELECTEDVALUE(Scenario[ScenarioID])
return
CALCULATETABLE(
SELECTCOLUMNS(ScenarioData, "ID", ScenarioData[ID]),
ScenarioData[ScenarioID] = _vSelecedScenario
)
--Not working
CALCULATETABLE(
SELECTCOLUMNS(ScenarioData, "ID", ScenarioData[ID]),
ScenarioData[ScenarioID] = 2
)
--working
What did I miss and how I can get these lists based on selected ScenarioID value?
Solved! Go to Solution.
You can try creating a measure like
__NewTest =
VAR _vAct =
VALUES ( Data[ID] )
VAR _vSc =
CALCULATETABLE ( VALUES ( ScenarioData[ID] ), REMOVEFILTERS ( 'Data' ) )
VAR _vNew =
EXCEPT ( _vAct, _vSc )
RETURN
CALCULATE ( SUM ( Data[Amount] ), _vNew )
and use that in a visual with columns from the Data table.
You can try creating a measure like
__NewTest =
VAR _vAct =
VALUES ( Data[ID] )
VAR _vSc =
CALCULATETABLE ( VALUES ( ScenarioData[ID] ), REMOVEFILTERS ( 'Data' ) )
VAR _vNew =
EXCEPT ( _vAct, _vSc )
RETURN
CALCULATE ( SUM ( Data[Amount] ), _vNew )
and use that in a visual with columns from the Data table.
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
89 | |
52 | |
48 | |
46 |