Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hola
Tengo 2 mesas
1. Tabla de pronóstico
2. Tabla del calendario
El pronóstico se registra a nivel mensual y la granularidad más baja es la combinación de País; Producto; Tipo;Dosis por mes. Y quiero cambiar esta granularidad al nivel de fecha.
Así que básicamente quiero sumar el valor del mes de cantidad de demanda y luego dividirlo por el número de días en el mes dado.
Con la ayuda de ChatGPT, logré crear un DAX funcional que me da la granularidad por fecha, pero no por fecha + "País; Producto; Tipo;Dosis".
¿Alguien sabe cómo puedo hacer esto?
Necesito esto para poder combinar la clave con una tabla de elementos.
Forecast qty per date =
VAR StartDate = MIN('_dimDate'[Date]) // Get the minimum date from the date table
VAR EndDate = MAX('_dimDate'[Date]) // Get the maximum date from the date table
RETURN
// Iterate through each date in the date table
ADDCOLUMNS(
FILTER(
'_dimDate',
'_dimDate'[Date] >= StartDate && '_dimDate'[Date] <= EndDate
),
"_dimDate", '_dimDate'[Date],
// Calculate the forecast value for the current date by distributing it evenly across all days in the month
"Forecast_Qty_per_date",
CALCULATE(
SUM('Forecast'[Demand_qty]),
DATESBETWEEN(
'_dimDate'[Date],
DATE(YEAR('_dimDate'[Date]), MONTH('_dimDate'[Date]), 1),
DATE(YEAR('_dimDate'[Date]), MONTH('_dimDate'[Date]), DAY(EOMONTH('_dimDate'[Date], 0)))
)
) / (DAY(EOMONTH('_dimDate'[Date], 0))) - DAY(DATE(YEAR('_dimDate'[Date]), MONTH('_dimDate'[Date]), 1)) + 1
)
Vista del modelo de datos:
Probar
Forecast qty per date =
VAR SummaryTable =
ADDCOLUMNS (
SUMMARIZE (
'Forecast',
'Forecast'[Country],
'Forecast'[Product],
'Forecast'[Type],
'Forecast'[Doses per month],
'Forecast'[DateKey]
),
"@End of month", EOMONTH ( 'Forecast'[DateKey], 0 ),
"@Days in month", DATEDIFF ( 'Forecast'[DateKey], EOMONTH ( 'Forecast'[DateKey], 0 ), DAY ) + 1,
"@Total qty", CALCULATE ( SUM ( 'Forecast'[Demand_qty] ) )
)
VAR DailySummary =
ADDCOLUMNS (
GENERATE ( SummaryTable, CALENDAR ( 'Forecast'[DateKey], [@End of month] ) ),
"@Daily amount", DIVIDE ( [@Total qty], [@Days in month] )
)
RETURN
DailySummary