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
Pascal_KTeam
Resolver I
Resolver I

Selection from Slicer as column in virtual table

Hi all. I'm trying my best to describe the issue I have...

 

I need to create a virtual table which includes one column that shows the selection from a slicer

 

Slicer:

 

I have a slicer to select Business Unit. I also have a measure which gives me the selected item from the slicer with SELECTEDVALUE

 

physical Table:

 

I have a table with data from different Business Units

 

virtual table:

 

I have a virtual table which is based on the physical table from above but I add a couple of columns with ADDCOLUMNS. So far all good.

 

Since I need the virtual table to be filtered to only the Business unit which is selected in the slicer, I was trying to add the result of the SELECTEDVALUE measure from above to a new column but this doesn't work. It stays blank. The formulare for the virtual table looks like this:

 

I'm looking for a way to replace the hardcoded "Business Unit XY" wich what is selected in the slicer

 

HL Virtual =

 

VAR newTable =

ADDCOLUMNS(HL_Template;

    "RATETYPE";

        LOOKUPVALUE('Data'[RATETYPE];'Data'[MG_ACCOUNT ID];HL_Template[MG_ACCOUNT]);

     "Selected Unit";

        "Business Unit XY")

VAR filteredtable =

    SELECTCOLUMNS(newTable;

        "MG_ACCOUNT";HL_Template[MG_ACCOUNT];"Unit";HL_Template[Unit];"RATETYPE";[RATETYPE];"Selected Unit";[Selected Unit];"Unit = selected Unit";IF(HL_Template[Unit]=[Selected Unit];"YES";"NO"))

 

RETURN

FILTER(filteredtable;[Unit = selected Unit]="YES")

 

I'm happy for any hints in the right direction. Thanks guys!

1 ACCEPTED SOLUTION

I had to rethink the whole topic and now successfully created a measure which is doing what I need. 

Of course, calculated columns are calculated on refresh so this wasn't actually an option

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Sample data would be great. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Basically I start with 2 tables (linked Excel file might make it even clearer, at least I hope so: Excel File with details ) 

Table name:Data  
what's in there:all data  
Source:ERP  
    
RATETYPEACCOUNTBusiness UnitAmount
notransacc001unit1100
notransacc002unit2200
transacc003unit1300
transacc004unit2400

 

and

 

Table name:HL Template
Wha'ts in there:template which shows the accounts that should be shown in the report. Note that for unit1 we don't want to see acc002 and therefore haven't listed it in the template. 
SourceSource: manually created Excel file
  
Business UnitAccount
unit1acc001
unit2acc003
unit2acc004

 

Then I create a 3rd table "Calc Table" using DAX. Basically I take table HL Template and add some columns from the Data table. This works fine. What I also need in the "Calc Table" is a column which shows which Business Unit is currently selected in a slicer which is linked to the Data table. So the red marked part of the DAX needs to be replaced

 

Calc Table =

VAR newTable =
ADDCOLUMNS(HL_Template;
    "RATETYPE";
        LOOKUPVALUE('Data'[RATETYPE];'Data'[ACCOUNT];HL_Template[ACCOUNT]);
     "Selected Unit";
        "Business Unit XY")
VAR filteredtable =
    SELECTCOLUMNS(newTable;
        "ACCOUNT";HL_Template[ACCOUNT];"Business Unit";HL_Template[Business Unit];"RATETYPE";[RATETYPE];"Selected Unit";[Selected Unit];"Unit = selected Unit";IF(HL_Template[Unit]=[Selected Unit];"YES";"NO"))

RETURN
FILTER(filteredtable;[Unit = selected Unit]="YES")

 

I had to rethink the whole topic and now successfully created a measure which is doing what I need. 

Of course, calculated columns are calculated on refresh so this wasn't actually an option

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.