Forum Discussion
Date Year Functions in DAX Issue
- Anonymous3 years ago
Hi jayasurya_prud ,
Are table and table the same table? There is no [no of grad] in the sample data, and I try to make you understand how to dynamically group calculations.
Since you want dynamic results. If it's a calculated column, please try
year column = var counts = CALCULATE(COUNTROWS('Table'),FILTER('Table',[Year_String]=MAX('Table'[Year_String]))) var grads_attr =CALCULATE(COUNTROWS('Table'),FILTER('Table',[no of years] = 1&&[Not Active]<>"Yes"&&[Year_String] =MAX('Table'[Year_String]))) return counts - grads_attrIf it's a measure, please try
year measure = var counts = CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[Year_String]=MAX('Table'[Year_String]))) var grads_attr =CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[no of years] = 1&&[Not Active]<>"Yes"&&[Year_String] =MAX('Table'[Year_String]))) return counts-grads_attrWe often use FILTER(ALLSELECTED('Table'),[Year_String]=MAX('Table'[Year_String]) to group in measures and use FILTER('Table',[Year_String]=EARLIER('Table'[Year_String]) to group in calcualted columns.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi! Thanks for replying with the dax. I am afraid that this is not working. Here is the sample data
| S_ID | Year_String | Year_num | no of years | Grad | Not Active |
| 1 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 2 | 2021 - 22 | 2021 | 2 | no | no |
| 3 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 4 | 2019 - 20 | 2019 | 4 | no | no |
| 5 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 6 | 2017 - 18 | 2017 | 6 | no | no |
| 7 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 8 | 2021 - 22 | 2021 | 2 | no | no |
| 9 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 10 | 2019 - 20 | 2019 | 4 | no | no |
| 11 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 12 | 2017 - 18 | 2017 | 6 | no | no |
| 13 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 14 | 2021 - 22 | 2021 | 2 | no | no |
| 15 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 16 | 2019 - 20 | 2019 | 4 | no | no |
| 17 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 18 | 2017 - 18 | 2017 | 6 | no | no |
| 19 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 20 | 2021 - 22 | 2021 | 2 | no | no |
| 21 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 22 | 2019 - 20 | 2019 | 4 | no | no |
| 23 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 24 | 2017 - 18 | 2017 | 6 | no | no |
| 25 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 26 | 2021 - 22 | 2021 | 2 | no | no |
| 27 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 28 | 2019 - 20 | 2019 | 4 | no | no |
| 29 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 30 | 2017 - 18 | 2017 | 6 | no | no |
| 31 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 32 | 2021 - 22 | 2021 | 2 | no | no |
| 33 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 34 | 2019 - 20 | 2019 | 4 | no | no |
| 35 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 36 | 2017 - 18 | 2017 | 6 | no | no |
| 37 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 38 | 2021 - 22 | 2021 | 2 | no | no |
| 39 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 40 | 2019 - 20 | 2019 | 4 | no | no |
| 41 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 42 | 2017 - 18 | 2017 | 6 | no | no |
| 43 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 44 | 2021 - 22 | 2021 | 2 | no | no |
| 45 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 46 | 2019 - 20 | 2019 | 4 | no | no |
| 47 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 48 | 2017 - 18 | 2017 | 6 | no | no |
| 49 | 2022 - 23 | 2022 | 1 | yes | Yes |
| 50 | 2021 - 22 | 2021 | 2 | no | no |
| 51 | 2020 - 21 | 2020 | 3 | yes | Yes |
| 52 | 2019 - 20 | 2019 | 4 | no | no |
| 53 | 2018 - 19 | 2018 | 5 | yes | Yes |
| 54 | 2017 - 18 | 2017 | 6 | no | no |
I want help of date function in the filter. This is the dax I am trying
Hi jayasurya_prud ,
Are table and table the same table? There is no [no of grad] in the sample data, and I try to make you understand how to dynamically group calculations.
Since you want dynamic results. If it's a calculated column, please try
year column =
var counts = CALCULATE(COUNTROWS('Table'),FILTER('Table',[Year_String]=MAX('Table'[Year_String])))
var grads_attr =CALCULATE(COUNTROWS('Table'),FILTER('Table',[no of years] = 1&&[Not Active]<>"Yes"&&[Year_String] =MAX('Table'[Year_String])))
return counts - grads_attr
If it's a measure, please try
year measure =
var counts = CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[Year_String]=MAX('Table'[Year_String])))
var grads_attr =CALCULATE(COUNTROWS('Table'),FILTER(ALLSELECTED('Table'),[no of years] = 1&&[Not Active]<>"Yes"&&[Year_String] =MAX('Table'[Year_String])))
return counts-grads_attr
We often use FILTER(ALLSELECTED('Table'),[Year_String]=MAX('Table'[Year_String]) to group in measures and use FILTER('Table',[Year_String]=EARLIER('Table'[Year_String]) to group in calcualted columns.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.