Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hola, tengo una tabla de hechos para los atributos de contacto que contiene instantáneas de principios de trimestre más hoy. Esto se utiliza para agregar totales de contactos en cada período de tiempo de instantánea. Ejemplo a continuación agregado para simplificar:
AS_OF_DATE | TOTAL CONTACTOS |
1/1/2023 | 1 |
4/1/2023 | 1 |
4/13/2023 | 2 |
También tengo una tabla de objetivos que muestra las expectativas de objetivos para cada trimestre. Estas son expectativas de fin de trimestre.
FECHA OBJETIVO | CONTACTOS OBJETIVO |
1/1/2023 | 1 |
4/1/2023 | 2 |
7/1/2023 | 3 |
Aquí está mi problema:
Como no tenemos totales de contactos de fin de trimestre, si estoy dentro del mismo trimestre, solo necesito ver cuántos contactos tenemos frente al objetivo (esto se calcula correctamente). Sin embargo, si se completa el trimestre, necesito comparar el total de contactos para la fecha de inicio del trimestre SIGUIENTE con el objetivo del trimestre anterior. ¿Alguna idea de cómo puedo hacer eso?
Solved! Go to Solution.
Parece que he resuelto esto. Estoy seguro de que hay una manera más elegante de manejar esto, pero por el bien de la posteridad, esto es lo que hice. Es una columna calculada que básicamente cambia los recuentos de contactos hacia atrás un período con algún manejo de excepciones para los números del trimestre actual.
Contact Total_Next Date =
var maxperiod=calculate(max('CONTACT'[AS_OF_DATE]),ALLEXCEPT('CONTACT','CONTACT'[ID])) // max as_of_date with no filters except ID
var actualperiod='CONTACT'[AS_OF_DATE] //as_of_date of the row
var nextperiod=calculate(MIN('CONTACT'[AS_OF_DATE]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]>actualperiod) //min as_of_date after as_of_date of row
var actualscontact=calculate(MAX('CONTACT'[CONTACT_COUNT]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]=actualperiod) //max contact count for as_of_date of row
var nextcontact=calculate(MIN('CONTACT'[CONTACT_COUNT]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]=nextperiod) //min contact count of next as_of_date
return
if(actualperiod=maxperiod,'CONTACT'[CONTACT_COUNT], //if as_of_date = max period then contact count
if(actualperiod = CALCULATE(max(DATE_T[DATE]),DATE_T[CURRENT_MONTH_INT]=0),'CONTACT'[CONTACT_COUNT], //if beginning of current quarter then use beginning of quarter count
nextcontact //if min period = as_of_date of row, then just do contact_count, else do max count for row - max count for prior row))
))
Parece que he resuelto esto. Estoy seguro de que hay una manera más elegante de manejar esto, pero por el bien de la posteridad, esto es lo que hice. Es una columna calculada que básicamente cambia los recuentos de contactos hacia atrás un período con algún manejo de excepciones para los números del trimestre actual.
Contact Total_Next Date =
var maxperiod=calculate(max('CONTACT'[AS_OF_DATE]),ALLEXCEPT('CONTACT','CONTACT'[ID])) // max as_of_date with no filters except ID
var actualperiod='CONTACT'[AS_OF_DATE] //as_of_date of the row
var nextperiod=calculate(MIN('CONTACT'[AS_OF_DATE]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]>actualperiod) //min as_of_date after as_of_date of row
var actualscontact=calculate(MAX('CONTACT'[CONTACT_COUNT]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]=actualperiod) //max contact count for as_of_date of row
var nextcontact=calculate(MIN('CONTACT'[CONTACT_COUNT]),ALLEXCEPT('CONTACT','CONTACT'[ID]),'CONTACT'[AS_OF_DATE]=nextperiod) //min contact count of next as_of_date
return
if(actualperiod=maxperiod,'CONTACT'[CONTACT_COUNT], //if as_of_date = max period then contact count
if(actualperiod = CALCULATE(max(DATE_T[DATE]),DATE_T[CURRENT_MONTH_INT]=0),'CONTACT'[CONTACT_COUNT], //if beginning of current quarter then use beginning of quarter count
nextcontact //if min period = as_of_date of row, then just do contact_count, else do max count for row - max count for prior row))
))