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,
I have a sales table of which goes back 10 years. Within this I have:
cust_id
items
date
What I'd like is a Column which will output the year of their first purchase.
If purchase_date was made in 2023 but no record of purchase before then, then 2023 if first purchase date was made in 2022 then 2022 etc.
The difficulty I think is based on someone buying multiple items
Cust_id. items. date. New col
1. Football. 01/02/2024 2023
1. Rugby ball. 14/09/2023 2023
1. Hockey stick. 12/06/2023 2023
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a new column.
INDEX function (DAX) - DAX | Microsoft Learn
expected_result_calculated_column =
YEAR (
MINX (
INDEX (
1,
data,
ORDERBY ( data[date], ASC ),
,
PARTITIONBY ( data[cust_id] ),
MATCHBY ( data[cust_id], data[items], data[date] )
),
data[date]
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
It is for creating a new column.
INDEX function (DAX) - DAX | Microsoft Learn
expected_result_calculated_column =
YEAR (
MINX (
INDEX (
1,
data,
ORDERBY ( data[date], ASC ),
,
PARTITIONBY ( data[cust_id] ),
MATCHBY ( data[cust_id], data[items], data[date] )
),
data[date]
)
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
You can try this as a calculated column @M_SBS_6
First =
CALCULATE(
MIN('Table'[Date]),
FILTER(
'Table',
'Table'[Cust ID] = EARLIER( 'Table'[Cust ID])
)
)
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 |
---|---|
97 | |
96 | |
81 | |
74 | |
66 |
User | Count |
---|---|
126 | |
105 | |
103 | |
81 | |
72 |