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.
Hi All,
Could somebody help me to write the below SQL statement in DAX.
No of repeat orders from existing customer
select count(distinct ord_cd),Ord_Cust_Id from FCT_ORD_LINE ord inner join DIM_STS STS on STS.Sts_Id= ORD.Ord_Sts_Id
AND STS.Sts_Text NOT IN ('Cancelled','Expired') where Ord_Crt_Dt between (Period) and Ord_Cust_Id in (sel Ord_Cust_Id from FCT_ORD_LINE ord inner join DIM_STS STS on STS.Sts_Id= ORD.Ord_Sts_Id AND STS.Sts_Text NOT IN ('Cancelled','Expired')
where Ord_Crt_Dt < Period ))"
Thanks & Regards,
Rajeev
Solved! Go to Solution.
Hi @Anonymous,
First, you can type the SQL statement when you import data from SQL Server, type the SQL statement in the following box(highlighted in red line).
In your model, you import FCT_ORD_LINE and DIM_STS tables seperately, please follow the steps below.
1. Create a relationship between FCT_ORD_LINE and DIM_STS tables trough STS.Sts_Id= ORD.Ord_Sts_Id.
2. Create a measure using the formula below.
measure = CALCULATE ( DISTINCTCOUNT ( [ord_cd] ), FILTER ( DIM_STS, [Sts_Text}<>'Cancelled'||[Sts_Text}<>'Expired'||[Ord_Crt_Dt] < Period ) )
3. Create a table visual, select [Ord_Cust_Id] and [measure] as values level, you will get expected result.
Best Regards,
Angelia
Hi @Anonymous,
First, you can type the SQL statement when you import data from SQL Server, type the SQL statement in the following box(highlighted in red line).
In your model, you import FCT_ORD_LINE and DIM_STS tables seperately, please follow the steps below.
1. Create a relationship between FCT_ORD_LINE and DIM_STS tables trough STS.Sts_Id= ORD.Ord_Sts_Id.
2. Create a measure using the formula below.
measure = CALCULATE ( DISTINCTCOUNT ( [ord_cd] ), FILTER ( DIM_STS, [Sts_Text}<>'Cancelled'||[Sts_Text}<>'Expired'||[Ord_Crt_Dt] < Period ) )
3. Create a table visual, select [Ord_Cust_Id] and [measure] as values level, you will get expected result.
Best Regards,
Angelia
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |