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 dataset with the year of birth from customers and the transaction date.
The year of birth table is polluted since I got next to normal year of birth also 2, 560 and 2030 but also textual values.
Since we receive this data from other organizations and it is provided to me through live connection with a tabular model I can't correct or clean this data.
What I want to do is writing a measure that calculates the age of a customer on the moment the person did a transaction (to find out how many transaction (and average) are made by each age).
So I wrote the DAX query below. Only I have a few issues and some questions with that right now. Hopefully somebody can help we this.
1. In the calculating of the age I escape the textual values. But I do want to give them the age value "Onbekend". How do I do this?
2. In the output I see that ages above 100 go to the category "Onbekend". How is this possible since my variable age_c isn't being called after the return?
3. I see some strange values in the output. 0000 converts to the age 0, 1907 to -1907, 1909 to -1909 (while 1908 gives me a correct value), 4 to -4, 5 tot -5 while 6, 7 and 8 give me the right age value again. How is this possible?
4. In my age categories everything goes like it should be, except for the age value 0 which is mapped to "Onbekend" instead of "0-4".
5. Can this DAX query be written better/shorter e.g. by swapping if for switch?
Many thank!
Kind regards,
Hans
Solved! Go to Solution.
Hi @Anonymous
I would suggest you create two measures.One measure is Age. The other measure is the Age category.If you need further help,please paste some data sample and expected output here or upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.
How to Get Your Question Answered Quickly
Regards,
Cherie
Hi @Anonymous
I would suggest you create two measures.One measure is Age. The other measure is the Age category.If you need further help,please paste some data sample and expected output here or upload the .pbix file to OneDrive and post the link here. Do mask sensitive data before uploading.
How to Get Your Question Answered Quickly
Regards,
Cherie
Hi,
In the DAX I already made 2 measures (one as a variable in the other).
Please see the examples below.
Customer_IDTransaction_Date
1 | 17-11-2018 |
7 | 18-11-2018 |
15 | 19-11-2018 |
1 | 20-11-2018 |
1 | 20-11-2018 |
1 | 20-11-2018 |
4 | 21-11-2018 |
5 | 21-11-2018 |
6 | 21-11-2018 |
3 | 21-11-2018 |
3 | 21-11-2018 |
6 | 22-11-2018 |
Customer_IDYear of Birth
1 | O |
2 | BA |
3 | 2 |
4 | 560 |
5 | 1890 |
6 | 1895 |
7 | 1900 |
8 | 1913 |
9 | 1931 |
10 | 1975 |
11 | 1990 |
12 | 1993 |
13 | 1998 |
14 | 2018 |
15 | 2028 |
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 |
---|---|
113 | |
99 | |
80 | |
70 | |
59 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |