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
martcatnip
Frequent Visitor

Measure to Column

Hi,

I currently have a measure

VAR __SelectedDate = MAX('Log_Activation'[DateTime])
VAR __Table1 = FILTER(ALL('Log_Activation'),[DateTime]<=__SelectedDate)
VAR __Table2 = FILTER(ALL('Log_Activation'),[DateTime]<__SelectedDate)
VAR __Device1 = DISTINCT(SELECTCOLUMNS(__Table1,"Device",[Name]))
VAR __Device2 = DISTINCT(SELECTCOLUMNS(__Table2,"Device",[Name]))
VAR __Table = EXCEPT(__Device1, __Device2)
VAR __Devices = DISTINCT(SELECTCOLUMNS(__Table,"Device",[Device]))
RETURN
CONCATENATEX(__Devices,[Device],",")

 

I am wondering if there is any way I can change it to a column.


Thanks

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @martcatnip ,

 

As @Greg_Deckler  said, if you want dynamic results, calculated columns are not recommended. If it is a static result, you can modify it to

 

Calculated Column =
VAR __Table1 =
    FILTER (
        ALL ( 'Log_Activation' ),
        [DateTime] <= EARLIER ( 'Log_Activation'[DateTime] )
    )
VAR __Table2 =
    FILTER (
        ALL ( 'Log_Activation' ),
        [DateTime] < EARLIER ( 'Log_Activation'[DateTime] )
    )
VAR __Device1 =
    DISTINCT ( SELECTCOLUMNS ( __Table1, "Device", [Name] ) )
VAR __Device2 =
    DISTINCT ( SELECTCOLUMNS ( __Table2, "Device", [Name] ) )
VAR __Table =
    EXCEPT ( __Device1, __Device2 )
VAR __Devices =
    DISTINCT ( SELECTCOLUMNS ( __Table, "Device", [Device] ) )
RETURN
    CONCATENATEX ( __Devices, [Device], "," )

 

 

The calculated column will use EARLIER to get the current row.

 

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

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @martcatnip ,

 

As @Greg_Deckler  said, if you want dynamic results, calculated columns are not recommended. If it is a static result, you can modify it to

 

Calculated Column =
VAR __Table1 =
    FILTER (
        ALL ( 'Log_Activation' ),
        [DateTime] <= EARLIER ( 'Log_Activation'[DateTime] )
    )
VAR __Table2 =
    FILTER (
        ALL ( 'Log_Activation' ),
        [DateTime] < EARLIER ( 'Log_Activation'[DateTime] )
    )
VAR __Device1 =
    DISTINCT ( SELECTCOLUMNS ( __Table1, "Device", [Name] ) )
VAR __Device2 =
    DISTINCT ( SELECTCOLUMNS ( __Table2, "Device", [Name] ) )
VAR __Table =
    EXCEPT ( __Device1, __Device2 )
VAR __Devices =
    DISTINCT ( SELECTCOLUMNS ( __Table, "Device", [Device] ) )
RETURN
    CONCATENATEX ( __Devices, [Device], "," )

 

 

The calculated column will use EARLIER to get the current row.

 

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.

Greg_Deckler
Super User
Super User

@martcatnip In your case, no if you want it to remain dynamic based upon user interaction. Calculated columns are only recaculated at the time of data load/refresh. Now, if it doesn't need to be dynamic and your "__SelectedDate" can be based on something like a [Date] column in your table, then just set it to that and in theory the rest of the formula looks like it should be just fine.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors