Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (11.1k points)

How can I create a visual column stored in a DAX Variable,I have used the code below

measure = 

VAR min_dates = 

//get the min order date for each customer
SUMMARIZECOLUMNS(Orders[Customer ID],"min_date",MIN(Orders[Order Date]))

RETURN

min_dates

// what I want to do here is take the table I created above (min_dates) and do the following: 
// 1) group_by min_date
// 2) count(distinct) Customer ID

// What I'm struggling with is how to reference the columns created in the min_dates table above. 
 

1 Answer

0 votes
by (22.5k points)
edited by

Use the following measure 

UniqueCustomers =
VAR t1 =
    ADDCOLUMNS (
        orders,
        "Rank", RANKX (
            FILTER ( ALL ( Orders ), [CustomerID] = EARLIER ( Orders[CustomerID] ) ),
            [Order Date],
            ,
            ASC,
            DENSE
        )
    )
RETURN
    CALCULATE ( DISTINCTCOUNT ( Orders[CustomerID] ), FILTER ( t1, [Rank] = 1 ) )

Are you willing to learn power bi? Check the Power BI Developer blog from Intellipaat

Check the following youtube link: 

Browse Categories

...