Forum Discussion

andreyinfo's avatar
andreyinfo
Frequent Visitor
6 years ago
Solved

Help needed - How to create a single row table with the value from a selectedvalue.

I need to create a table and then with this table, to create another table. But the first table need to be created from a selection.

Tried everything and I just can't go on.
The measure getting the selectedvalue:

 

 

Selected = SELECTEDVALUE(dProducts[ProductCode])

 

 

The first table attempt :

 

 

FilteredBySelectedValue = 
Var _ProductCode = [Selected]
Return
ROW( "ProductCode",_ProductCode)

 

 

The second table attempt :

 

 

fBasketRelated = 
FILTER(
CROSSJOIN(
VALUES(FilteredBySelectedValue[ProductCode]),SELECTCOLUMNS( VALUES( fSalesDetails[ProductCode]),"RProductCode",[ProductCode])),[ProductCode]>[RProductCode])

 

 


The result : Nowhere.

f1

The model :

f2
stevedep 


 The PBI file 

  • Anonymous's avatar
    Anonymous
    6 years ago
    That's not possible. Tables in a model are always static and loaded at load time (then set in stone!).

    Secondly, you can only create table variables in dynamic code that describes measures but such tables are gone as soon as the measure's been calculated.

    Best
    D

6 Replies

  • I think it depends what you expect to do with the result.  If you start constructing a table from a selectedvalue in a filter context then you can use that table in memory and transform it as needed but the final return value needs to be scalar (a count of rows, or a CONCATENATEX of values).

    • andreyinfo's avatar
      andreyinfo
      Frequent Visitor

      So, if got it right, my final result needs to be a measure, because a table return more than one result.

      If so, there is no solution for my needs?

      Because I need to create a table : 

       

      Table = 
      FILTER(
          CROSSJOIN(
              VALUES(FilteredBySelectedValue[ProductCode]),SELECTCOLUMNS( VALUES( fSalesDetails[ProductCode]),"RProductCode",[ProductCode])),[ProductCode]>[RProductCode])

       


       And the first values ("VALUES(FilteredBySelectedValue[ProductCode])") needs to come from a selectedvalue.

       

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        your final result type must match the type of the original value.  

         

        How do you expect to consume the table that you created out of  a scalar value?