Forum Discussion
How to remove/exclude data from query
- 3 years ago
Anonymous ,
Hi,
1 Go to Add Column in top menu.
2 Click on Custom Column
3 Add following code.
Please change [source.name] and [DateColumn] as your table.if [source.name] = "Excel 1 - All" and Date.MonthName( [DateColumn]) = "May" then "True" else
if [source.name] = "Excel 2 - All" and Date.MonthName( [DateColumn]) = "June" then "True" else
if [source.name] = "Excel 3 - All" and Date.MonthName( [DateColumn]) = "July" then "True" else
if [source.name] = "Excel 4 - All" and Date.MonthName( [DateColumn]) = "August" then "True" else "False"Thank you.
- Anonymous3 years ago
Hi Anonymous ,
No, you can update the formula as below:
1. If the year of the data column is equal to 2021
if [source.name] = "Excel 1 - All.xls"
and Date.Year([DateColumn]) = 2021
and Date.MonthName([DateColumn]) = "May"
then "True"
else "False"2. If the year of the data column is equal to the year of current date
if [source.name] = "Excel 1 - All.xls"
and Date.Year([DateColumn]) = Date.Year(DateTime.LocalNow())
and Date.MonthName([DateColumn]) = "May"
then "True"
else "False"Best Regards
Sorry how do u do with switch case?
For if function can provide step by step?
Thanks.
Anonymous ,
Hi,
1 Go to Add Column in top menu.
2 Click on Custom Column
3 Add following code.
Please change [source.name] and [DateColumn] as your table.
if [source.name] = "Excel 1 - All" and Date.MonthName( [DateColumn]) = "May" then "True" else
if [source.name] = "Excel 2 - All" and Date.MonthName( [DateColumn]) = "June" then "True" else
if [source.name] = "Excel 3 - All" and Date.MonthName( [DateColumn]) = "July" then "True" else
if [source.name] = "Excel 4 - All" and Date.MonthName( [DateColumn]) = "August" then "True" else "False"
Thank you.
- Anonymous3 years agoNot applicable
Hi Dinesh,
IT worked! If I only want to see data for the month and year(May,2022), What should i change to the code? Because in the data there are other years too (2019, 2020, 2021). Currently it is giving me all the May dates in different years. Thanks again.
CheersDarren
- Dinesh_Suranga3 years agoContinued Contributor
Anonymous
Do you have separate calendar table?
- Anonymous3 years agoNot applicable
No, I don't. Only the date columns with all the dates.
Anyway we could edit the script to read the dates mm/yyyy (05/2022)? Maybe it might work? Thanks.