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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
patoku0207
Frequent Visitor

How to store filters results in a variable and use variable as filter ?

Hello

I  have a text filter where users can write a lot number and a table give the Item Numbers.

I want to store this lot number as a variable, so after I can filter the same table with this lot number on the receipt number

 

 

Item NumberLot NumberReceipt Number
90123C100025123547
90123C100026123548
90123C100027123549
90123D100045100026
90123D100046100089
90123E100085100026
90123E100087100089
90123F10024F100010
90123F10024G100026
90123F10024H100087

 

Ex :  if I write 100026 in my  text filter I want to see : 

 

90123D100045100026
90123E100085100026
90123F10024G100026

 

Its like twice filters applied.

I cant use SELECTEDVALUES( function not recognized)  because I'm not in imported datas but I use direct query mode .

So How can I do that ?

Thanks in advance for your replies and sorry for my english, this is not my natural language

Pat

4 REPLIES 4
patoku0207
Frequent Visitor

Hi and thanks for your answer.

I cant create a calculated table in Desktop ans i cant use SELECTEDVALUE because I use SSAS for my datas and direct query in Desktop

 

Best Regards

Patrice

Anonymous
Not applicable

Hi  @patoku0207 ,
You can test this by following the steps in my pbix file. If my answer is correct, please mark it as accept as solution.

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Anonymous
Not applicable

Hi @patoku0207 ,
After my testing, both mixed mode (IMPORT & DIRECT QUERY), and through the live connection mode directly to SSAS, can create calculate table and use selectedvalue, values dax functions.

Best regards

Albert He

Anonymous
Not applicable

Hi @patoku0207 ,
According to your description, I created a similar table in SQL Server and then used Direct Query mode in desktop to get the data.

Here some steps that I want to share, you can check them if they suitable for your requirement.

Here is my test data:

vheqmsft_0-1706078982783.png

1.Create a calculat table (This step changes the storage mode to Mixed but does not affect the previous use of your Direct query.)

Table 2 = VALUES('Table'[Lot Number])

2.Create a flag Measure to apply to your table visual's filters to show the correct filtered data

Flag = 
var _lot1=SELECTEDVALUE('Table 2'[Lot Number])
var _rnum=SELECTEDVALUE('Table'[Receipt Number])
return if(VALUE(_lot1)=_rnum,1,0) 

vheqmsft_1-1706079485261.png

3.Click the ... and get the text filter

vheqmsft_3-1706079609085.png

vheqmsft_2-1706079591156.png
4.Final output

vheqmsft_4-1706079651967.png

 

Best regards

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors