Forum Discussion
I need DAX for creating Exceptions(based on month selection {Total submissions- Last week submissio)
- 6 years ago
Hi Anonymous ,
We can use the following steps to meet your requirement.
1. We need to create three calculate columns to get month, month number and week num.
Month = FORMAT('query(16)'[Modified],"mmm")Month number = MONTH('query(16)'[Modified])week num = WEEKNUM('query(16)'[Modified],2)2. Then we can create the following measures to get the Total and Exceptions.
Total submissions = CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month])))Exceptions = var _max_week = CALCULATE(MAX('query(16)'[week num]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month]))) return CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[week num]=_max_week))new one Exception = var _max_week = CALCULATE(MAX('query(16)'[week num]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month]))) return [Total submissions] - CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[week num]=_max_week))If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
- Anonymous6 years ago
I'm used below mentioed DAX, after working fine my Application.
new one Exception =VAR _max_week =CALCULATE (MAX( 'query (16)'[week num] ),FILTER (ALL ('query (16)' ),'query (16)'[Month] = SELECTEDVALUE('query (16)'[Month])))var lastweekcount= CALCULATE([Total DU],FILTER('query (16)','query (16)'[week num]=_max_week))RETURN [Total DU]-lastweekcountThanks,
Hello,
Your mentioned DAX giving different behavior, please find attached sample excel data.
| DU_ID | Account | Modified |
| MFG | TEREX | 19-06-2020 23:12 |
| BFS | CITIGROUP-CTO-RISK | 09-06-2020 17:46 |
| CMT | EY | 28-06-2020 11:59 |
| BFS | CITIGROUP-CTO-RISK | 28-06-2020 14:54 |
| CMT | TIME WARNER | 19-07-2020 15:48 |
| CMT | CAMPBELL FOODS | 19-07-2020 23:35 |
| CMT | P&G | 19-07-2020 18:07 |
| CMT | P&G | 19-07-2020 18:02 |
| MFG | CHEVRON | 19-07-2020 10:54 |
| MFG | CHEVRON | 19-07-2020 03:59 |
| MFG | UTC GROUP (Carrier) | 17-07-2020 18:18 |
| MFG | UTC GROUP (Otis) | 19-07-2020 10:05 |
| NR | SCANIA | 19-07-2020 21:15 |
| NR | NETS HOLDINGS | 19-07-2020 11:18 |
| NR | NETS HOLDINGS | 19-07-2020 11:21 |
| NR | NETS HOLDINGS | 19-07-2020 11:27 |
| NR | NETS HOLDINGS | 19-07-2020 10:54 |
| NR | NETS HOLDINGS | 19-07-2020 11:09 |
| NR | NETS HOLDINGS | 19-07-2020 11:17 |
| INS | BB&T Insurance Services | 17-07-2020 20:17 |
| INS | ONEMAIN SOLUTIONS | 17-07-2020 10:27 |
| INS | ONEMAIN SOLUTIONS | 17-07-2020 10:28 |
| EU | VEOLIA-WATERS | 19-07-2020 22:50 |
| EU | VEOLIA-WATERS | 19-07-2020 22:54 |
| BFS | CITIGROUP-ICG-MSST | 19-07-2020 21:32 |
| MFG | CHEVRON | 19-07-2020 06:57 |
| MFG | PBF ENERGY | 17-07-2020 12:46 |
| MFG | PBF ENERGY | 17-07-2020 18:27 |
| MFG | PBF ENERGY | 17-07-2020 18:23 |
| MFG | PBF ENERGY | 17-07-2020 20:25 |
| MFG | JCI | 19-07-2020 15:54 |
| CMT | INGRAM MICRO | 17-07-2020 08:29 |
| MFG | CHEVRON | 17-07-2020 03:57 |
| MFG | CHEVRON | 15-07-2020 09:20 |
| Europe | Lafarge | 10-07-2020 20:07 |
| INS | INSURITY | 16-07-2020 19:49 |
| CMT | VIACOM-CMT | 15-07-2020 00:06 |
| INS | INSURITY | 19-07-2020 10:34 |
| BFS | CITIGROUP-CTO-FINANCE | 17-07-2020 16:23 |
| BFS | CITIGROUP-CTI-CATE | 19-07-2020 15:00 |
| BFS | CITIGROUP-ICG-TTS/CPB | 17-07-2020 18:48 |
| BFS | CITIGROUP-CITI-GCB | 19-07-2020 11:17 |
| BFS | CITIGROUP-CTO-COMPLIANCE | 19-07-2020 21:56 |
| BFS | CITIGROUP-CTO-RISK | 08-07-2020 08:13 |
| BFS | CITIGROUP-CTO-RISK | 15-07-2020 14:58 |
| BFS | CITIGROUP-CTO-RISK | 19-07-2020 19:54 |
| NR | NETS HOLDINGS | 19-07-2020 11:25 |
| NR | NETS HOLDINGS | 19-07-2020 12:21 |
| NR | NETS HOLDINGS | 19-07-2020 12:30 |
| NR | NETS HOLDINGS | 19-07-2020 12:36 |
| NR | NETS HOLDINGS | 19-07-2020 12:39 |
| MFG | Kaman | 19-07-2020 14:20 |
Thanks,
I.Ravi.,
Hi Anonymous ,
We can use the following steps to meet your requirement.
1. We need to create three calculate columns to get month, month number and week num.
Month = FORMAT('query(16)'[Modified],"mmm")
Month number = MONTH('query(16)'[Modified])
week num = WEEKNUM('query(16)'[Modified],2)
2. Then we can create the following measures to get the Total and Exceptions.
Total submissions =
CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month])))
Exceptions =
var _max_week = CALCULATE(MAX('query(16)'[week num]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month])))
return
CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[week num]=_max_week))
new one Exception =
var _max_week = CALCULATE(MAX('query(16)'[week num]),FILTER(ALLSELECTED('query(16)'),'query(16)'[Month]=MAX('query(16)'[Month])))
return
[Total submissions] - CALCULATE(COUNT('query(16)'[DU_ID]),FILTER(ALLSELECTED('query(16)'),'query(16)'[week num]=_max_week))
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BTW, pbix as attached.
- v-zhenbw-msft6 years ago
Community Support
Hi Anonymous ,
How about the result after you follow the suggestions mentioned in my original post?
Could you please provide more details or expected result about it If it doesn't meet your requirement?
If you've fixed the issue on your own please kindly share your solution.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
For your DAX function not working fine.
- Anonymous6 years agoNot applicable
I'm used below mentioed DAX, after working fine my Application.
new one Exception =VAR _max_week =CALCULATE (MAX( 'query (16)'[week num] ),FILTER (ALL ('query (16)' ),'query (16)'[Month] = SELECTEDVALUE('query (16)'[Month])))var lastweekcount= CALCULATE([Total DU],FILTER('query (16)','query (16)'[week num]=_max_week))RETURN [Total DU]-lastweekcountThanks,