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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tomas930115
Regular Visitor

Create table from existing one with the condition from the user

Actual =

VAR x = variables[var_2021]
VAR y = variables[var_2022]
VAR z = variables[var_RE]
VAR a = variables[var_BP23]

RETURN
SWITCH(
    TRUE(),
    [User_selection_actual] = variables[var_Slicer_option_Actual_1], CALCULATETABLE(query_all,query_all,query_all[Version]=x),
    [User_selection_actual] = variables[var_Slicer_option_Actual_2], CALCULATETABLE(query_all,query_all,query_all[Version]=y),
    [User_selection_actual] = variables[var_Slicer_option_Actual_3], CALCULATETABLE(query_all,query_all,query_all[Version]=z),
    [User_selection_actual] = variables[var_Slicer_option_Actual_4], CALCULATETABLE(query_all,query_all,query_all[Version]=a),

    "Select"
)
 
Hi, 
 
I am trying to create a new table from the existing table and it should take the condition from the user. So for instance, the user would pick Slicer_option_actual_1 and then it would create a new table that would filter from the old table the correct version of " Slicer_option_actual_1".
 
The error is: The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
 
I have googled this problem but could nto find it for the instance where the condition is based on the user. 
 
Thank you for your help
1 ACCEPTED SOLUTION

Hi @Tomas930115 ,

 

If you want a table visual displayed, it could be achieved.

vstephenmsft_0-1669009956769.png

If you want a calculated table created by dax, as @amitchandak  said, it's impossible.

Because calculated tables are static results, results are not dynamically updated because of slicer or filter filtering.

 

 

Best Regards,

Stephen Tao

 

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Tomas930115 , You can not create a table based on the selected value. As that will not be correct

 

 

For error

This may measure where are using that code

 

or you need a max here

[User_selection_actual] = max(ariables[var_Slicer_option_Actual_1])

I will illustrate the problem in this example:

 

Original Table:

VersionRevenueProduct
x10 
x10 
x10 
x10 
z20 
z20 
y30 
a40 

 

On PowerBi dashborad, I the user would select "version" for instance -> "x" and the new table would be created only with a rows version "x" 

New table:

VersionRevenueProduct
x10 
x10 
x10 
x10 

 

 

Hi @Tomas930115 ,

 

If you want a table visual displayed, it could be achieved.

vstephenmsft_0-1669009956769.png

If you want a calculated table created by dax, as @amitchandak  said, it's impossible.

Because calculated tables are static results, results are not dynamically updated because of slicer or filter filtering.

 

 

Best Regards,

Stephen Tao

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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