Forum Discussion
iplaygod
7 years agoResolver I
DAX how split a string by delimiter into a list or array?
NOTE: I am not trying to write calculated columns. I am writing dax inside measures. I am trying to use the result of one measure as the filter for another measure. This is to avoid having to re-...
- 7 years ago
I think,,,,In that case we can use this MEASURE :smileywink:
Measure 3 = VAR mymeasure = SUBSTITUTE ( [Measure], ",", "|" ) VAR Mylen = LEN ( mymeasure ) VAR mytable = ADDCOLUMNS ( GENERATESERIES ( 1, mylen ), "mylist", VALUE ( PATHITEM ( mymeasure, [Value] ) ) ) VAR mylist = SELECTCOLUMNS ( mytable, "list", [mylist] ) RETURN CALCULATE ( COUNTROWS ( Table1 ), Table1[ID] IN mylist ) - 7 years ago
TomMartensiplaygod
Ohh. YesThis was exactly in my mind. I just forgot to replace LEN when I copy pasted myfirst formula.
Measure 3 = VAR mymeasure = SUBSTITUTE ( [Measure], ",", "|" ) VAR Mylen = PATHLENGTH ( mymeasure ) VAR mytable = ADDCOLUMNS ( GENERATESERIES ( 1, mylen ), "mylist", VALUE ( PATHITEM ( mymeasure, [Value] ) ) ) VAR mylist = SELECTCOLUMNS ( mytable, "list", [mylist] ) RETURN CALCULATE ( COUNTROWS ( Table1 ), Table1[ID] IN mylist )
tondeli
7 years agoAdvocate I
First, this solution looks cool!! I've tried but can't get it to work...
I have a date table and I use date as a slicer and I allow users to choose multiple values.
I want to show all dates from my data table and calculate sum of sales from fact table per day . For the next column I'd like to show sales for selected dates.
Date - TotalSales - SelectedSales
This one works:
SalesSelectedDates =
calculate([SumSales];Calendar[Date] in {"22.2.2018";"23.2.2018";"23.3.2018";"1.4.2018";"5.5.2018"})
I created following measure for selected dates:
SelectedDates =
concatenatex(allselected(Calendar[Date]);Calendar[Date];", ")
I've added above measure to a card visualization and I can see following:
Next I've tried to copy your solution:
SalesSelectedDates2 = var selectedDates=substitute([SelectedDates];", ";"|") var selectionLEN=pathlength(selectedDates) var selectionTable=addcolumns(generateseries(1;selectionLEN);"List";value(pathitem(selectedDates;[Value]))) var selectionList=selectcolumns(selectionTable;"Dates";[List]) return ( calculate([SumSales];Calendar[Date] in selectionList) )
For me this calculates total sales from my fact and show it for each date. What I am doing wrong?
TomMartens
7 years agoSuper User
Hey, I assume that there is a relationship between your date table and your fact table.
Regards,
Tom
Regards,
Tom