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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bsas
Post Patron
Post Patron

Get selected value from slicer to filter caltulate table

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:

bsas_0-1686322231338.png

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?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

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. 

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

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. 

@johnt75  thank you! It's exactly what I need!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.