Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Bom dia a todos,
criei um aplicativo no Qlik para analise de vendas mensais, porém, meu mês é considerado como começando a partir do dia 21 e terminando no dia 20 do próximo mês. Por exemplo, o mês de Fevereiro começa a ser contabilizado em 21/01 e termina em 20/02. Já trouxe o calendário nesse formato para o script e criei duas variáveis, vDataAnalise (=Date(AddMonths(MakeDate(Year(Today()), Month(Today()), 20), 0), 'DD/MM/YYYY')) e vDataAnaliseMêsPassado (=Date(AddMonths(MakeDate(Year(Today()), Month(Today()), 21), -1), 'DD/MM/YYYY')), mas agora preciso criar um filtro que me permita filtrar essas datas de forma dinâmica. Quero selecionar, por exemplo, o mês de Novembro do ano passado e quero que o período retornado na minha tabela seja de 21/10/24 até 20/11/24. No momento o meu filtro pega apenas as datas do mês selecionado, sem considerar o período. Alguma sugestão do que devo fazer?
Agradeço desde já.
Hi @Wendel1304 , welcome to the community.
To dynamically filter data based on your custom month definition, I think you'll need to create a new field in your data model that explicitly maps each date to the correct "analytical month". Your calendar should assign each date to its corresponding analytical month and year based on your business logic. This means shifting dates that fall before the 21st to the previous month while keeping those from the 21st onward in the current period. Along with this, define the start and end dates for each analytical month to enable precise filtering. Then create a field that users can select, representing the analytical month in an intuitive way.
Hope this helps
Hi @Wendel1304 , welcome to the community.
To dynamically filter data based on your custom month definition, I think you'll need to create a new field in your data model that explicitly maps each date to the correct "analytical month". Your calendar should assign each date to its corresponding analytical month and year based on your business logic. This means shifting dates that fall before the 21st to the previous month while keeping those from the 21st onward in the current period. Along with this, define the start and end dates for each analytical month to enable precise filtering. Then create a field that users can select, representing the analytical month in an intuitive way.
Hope this helps
Thank you, it did help!
This is what I came up with and it worked.
''
if(criado_em >= '21/01/2022 00:00:01' and criado_em <= '20/02/2022 23:59:59', 'Fev/22',
if(criado_em >= '21/02/2022 00:00:01' and criado_em <= '20/03/2022 23:59:59', 'Mar/22',
if(criado_em >= '21/03/2022 00:00:01' and criado_em <= '20/04/2022 23:59:59', 'Abr/22',
if(criado_em >= '21/04/2022 00:00:01' and criado_em <= '20/05/2022 23:59:59', 'Mai/22', ...''
I explicitly mapped my dates to each correct month as you suggested. Thank you very much.
You're welcome.
To get more flexibility I would suggest you to map the dates dynamically, eliminating manual errors and automating updates when new data arrives.