Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

summarize and selectcolumns problems

Hi. I'm trying to SELECTCOLUMNS() to return a table with a single column [customer1] and then use SUMMARIZE() to count how many rows are present for each customer. This sounds fairly simple but I need to do it each month across a date range that is user-filterable.

 

I built a small demo model in Power BI to investigate the problem I am having with the "temp1" measure. The DAX is:

temp1 =
SUMMARIZE
(
SELECTCOLUMNS -- build a table with 1 column.
(
FILTER
(
cust_with_multiples,
cust_with_multiples[startdate] <= MAX ( 'date'[Date] )
&& cust_with_multiples[stopdate] > MAX ( 'date'[Date] )
)
,"customer1", cust_with_multiples[customer] -- the column to return from the selectcolumns().
)
, [customer1], "prods_pers_cust", COUNTROWS(cust_with_multiples[customer])
)
 
The "cust_with_multiples" table contains:
customerstartdatestopdate
a01/01/201726/12/2018
b31/01/201707/04/2018
c02/03/201716/05/2018
c01/04/201703/04/2018
c01/05/201729/10/2018
f31/05/201730/11/2018
g30/06/201722/11/2018
h30/07/201714/05/2019
i29/08/201730/05/2019
j28/09/201715/12/2018
k28/10/201726/10/2019
l27/11/201708/01/2019

 

And the "date" table is built by: 

date = CALENDAR(date(2017,1,1), date(2023,1,1))

 

My desired output from the temp1 measure would be like this:

customer  prods_pers_cust

a     1

b     1

c     3

f      1

....

 

Thanks.

2 Replies