Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
Thanks for taking the time to go through this.
I need to show the sum of a measure in a histogram and KPI, but only for a certain month-year. (current month year)
to show the date in a month-year format here is the expression I used :
=date(MonthStart(date(DateField,'DD/MM/YYYY')),'MMM-YYYY')
now showing the measure in tabular format looks like this:
I only want to show the value for Jun-2022 in my visualization.so I tried this for the KPI:
=Sum({< MonthYear_debitdate={"Jun-2022"} >} amount_collected)
No errors are thrown but Im getting the total of the measure across all dimension, ie 18258014315 as the value
What Have I done wrong? how do I fix this?
the format for MonthYear_debitdate is incorrect
You need to use the actual format of this field as it exist in the data model
Refer this article
https://community.qlik.com/t5/Qlik-Design-Blog/Dates-in-Set-Analysis/ba-p/1472511
alternatively you can also use below for calculations
=Sum({<debit_date={">=$(=Date(Monthstart(Max(debit_date))))<=$(=Date(Max(debit_date)))"} >} amount_collected)
Hola Devarshigoswami
Podrias poner tu metrica en el script y filtrar el periodo que necesitas con un where luego sumas y te quedaria un valor estatico con solo el periodo que necesitas.
Hize el siguiente script en el editor de codigo
T:
Load *
Where Periodo = Date(Today(),'MMM-YYYY');
LOAD * INLINE [
Venta, #Mes, Año, Mes, Periodo
50000, 1, 2022, Ene, ene-2022
45566, 2, 2022, Feb, feb-2022
34354, 3, 2022, Mar, mar-2022
32323, 4, 2022, Abr, abr-2022
67888, 5, 2022, May, may-2022
43322, 6, 2022, Jun, jun-2022
46462, 7, 2022, Jul, jul-2022
323232, 6, 2022, Jun, jun-2022
5654343, 5, 2022, May, may-2022
2224343, 6, 2022, Jun, jun-2022
343556, 6, 2022, Jun, jun-2022
2543547, 6, 2022, Jun, jun-2022
];
Resultado
Espero haber ayudado.
the format for MonthYear_debitdate is incorrect
You need to use the actual format of this field as it exist in the data model
Refer this article
https://community.qlik.com/t5/Qlik-Design-Blog/Dates-in-Set-Analysis/ba-p/1472511
alternatively you can also use below for calculations
=Sum({<debit_date={">=$(=Date(Monthstart(Max(debit_date))))<=$(=Date(Max(debit_date)))"} >} amount_collected)
Hola Devarshigoswami
Otra opción que vi hace poco que funciona es usar las funciones GetFieldSelections y GetPossibleCount
Paso 1
Crea una variable con la metrica
esto obtendra los datos del periodo que el usuario seleccione
paso 2
Crear una tabla o kpi con la expresion
IF(GetPossibleCount(periodo)=1,money(sum({<periodo={$(t)}>}Venta)),'Selecciona un periodo')
aca le estamos diciendo que si el usuario selecciona un registro del campo period, entonces sumas las ventas donde el periodo sea igual al valor que selecciono el usuario y si hizo mas de 1 filtro mostrara un texto
Resultado