Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Los ingresos se basan en posibles contratos y necesito pronosticar ingresos a lo largo de X años en función de la fecha de inicio/finalización.
Datos:
Id. de contrato | Nombre del contrato | Valor | Fecha de inicio | Fecha de finalización | Meses |
id0001 | (Nombre) | $1,000,000 | 01/05/2020 | 2/05/2021 | 13 |
id0002 | (Nombre) | $25,000,000 | 05/01/2021 | 05/01/2025 | 48 |
Gráficamente necesito ser capaz de mostrar 2020, 2021, 2022, ect. ingresos basados en los contratos.
Intenté usar GENERATESERIES para hacer las filas basadas en los meses, pero no puedo establecerla como una variable y debe ser difícil?
GENERATE ( TableName, GENERATESERIES ( 0, TableName[Month], 1 ) )
Estoy en una pérdida en cómo crear estos datos para que no estén codificados de forma rígida y se puedan expandir fácilmente a medida que nuestra empresa crece. He probado varias exquaciones DAX y no puedo clavarlo.
Cualquier comentario en absoluto sería muy apreciado.
Solved! Go to Solution.
Hola, @JustinNoe
Es un placer responder por ti.
Puedes hacerlo en pq.
Así:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykwxMDAwVNJR8kvMTQXRhgZgAGQZGOobmOobGRiBOUZQDliNsVKsDlSvEVQviDYyRWg21Qfqh6qHc0CKDI2UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Contract ID" = _t, #"Contract Name" = _t, Value = _t, #"Start Date" = _t, #"End Date" = _t, Months = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Contract ID", type text}, {"Contract Name", type text}, {"Value", Int64.Type}, {"Start Date", type date}, {"End Date", type date}, {"Months", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
x=(Date.Year([End Date])-Date.Year([Start Date]))*12+Date.Month([End Date])-Date.Month([Start Date]),
l=List.Generate(
()=>0,
each _<=x,
each _+1
)
in
l),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
Custom1 = Table.TransformRows(
#"Expanded Custom",
(x)=>
[
Contract ID=x[Contract ID],
Contract Name=x[Contract Name],
Value= let z=Table.RowCount(Table.SelectRows(#"Expanded Custom",(m)=>m[Contract ID]=x[Contract ID])) in x[Value]/z,
Start Date= let tab=Table.SelectRows(#"Expanded Custom",(y)=>y[Contract ID]=x[Contract ID]),min=Table.Min(tab,"Custom")[Custom] in if x[Custom]=min then x[Start Date] else Date.StartOfMonth( Date.AddMonths(x[Start Date],x[Custom])),
End Date=let tab=Table.SelectRows(#"Expanded Custom",(y)=>y[Contract ID]=x[Contract ID]),max=Table.Max(tab,"Custom")[Custom] in if x[Custom]=max then x[End Date] else Date.EndOfMonth( Date.AddMonths(x[Start Date],x[Custom])),
Month=x[Months]
]
),
#"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Contract ID", "Contract Name", "Value", "Start Date", "End Date", "Month"}, {"Contract ID", "Contract Name", "Value", "Start Date", "End Date", "Month"})
in
#"Expanded Column1"
Aquí está mi archivo .pbix de ejemplo. Espero que ayude.
Si no resuelve su problema, por favor no dude en preguntarme.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
El problema era el resultado de tener datos nulos, aunque los reemplaqué como un paso en la opción de transformación de datos.
Tan pronto como edité los datos del origen y se actualizó pude obtener los valores que se mostrarán correctamente.
Muchas gracias por tomarse el tiempo para ayudarme con esto.
Hola, @JustinNoe
Es un placer responder por ti.
Puedes hacerlo en pq.
Así:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykwxMDAwVNJR8kvMTQXRhgZgAGQZGOobmOobGRiBOUZQDliNsVKsDlSvEVQviDYyRWg21Qfqh6qHc0CKDI2UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Contract ID" = _t, #"Contract Name" = _t, Value = _t, #"Start Date" = _t, #"End Date" = _t, Months = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Contract ID", type text}, {"Contract Name", type text}, {"Value", Int64.Type}, {"Start Date", type date}, {"End Date", type date}, {"Months", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let
x=(Date.Year([End Date])-Date.Year([Start Date]))*12+Date.Month([End Date])-Date.Month([Start Date]),
l=List.Generate(
()=>0,
each _<=x,
each _+1
)
in
l),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
Custom1 = Table.TransformRows(
#"Expanded Custom",
(x)=>
[
Contract ID=x[Contract ID],
Contract Name=x[Contract Name],
Value= let z=Table.RowCount(Table.SelectRows(#"Expanded Custom",(m)=>m[Contract ID]=x[Contract ID])) in x[Value]/z,
Start Date= let tab=Table.SelectRows(#"Expanded Custom",(y)=>y[Contract ID]=x[Contract ID]),min=Table.Min(tab,"Custom")[Custom] in if x[Custom]=min then x[Start Date] else Date.StartOfMonth( Date.AddMonths(x[Start Date],x[Custom])),
End Date=let tab=Table.SelectRows(#"Expanded Custom",(y)=>y[Contract ID]=x[Contract ID]),max=Table.Max(tab,"Custom")[Custom] in if x[Custom]=max then x[End Date] else Date.EndOfMonth( Date.AddMonths(x[Start Date],x[Custom])),
Month=x[Months]
]
),
#"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"Contract ID", "Contract Name", "Value", "Start Date", "End Date", "Month"}, {"Contract ID", "Contract Name", "Value", "Start Date", "End Date", "Month"})
in
#"Expanded Column1"
Aquí está mi archivo .pbix de ejemplo. Espero que ayude.
Si no resuelve su problema, por favor no dude en preguntarme.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
¡Muchas gracias por tomarse el tiempo para poner todo eso juntos para mí!
Me estoy enojendo con este mensaje de error y no puedo corregirlo. ¿Tiene alguna sugerencia sobre qué puede estar causando esto?
Hola, @JustinNoe
¿Puede compartir la captura de pantalla del resultado de custom1?
Tal vez el formato de resultado de custom1 entra en conflicto con el formato admitido por la función fromlist.
Saludos
Janey Guo
Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Tengo curiosidad si es un problema con mis datos. A pesar de que he entrado y reemplazado las valuues de "null" para algunas de las fechas de inicio / fin y el importe del valor (algunos contratos que no tenemos información en este momento), ¿sigue viendo el valor nulo original y, por lo tanto, lanzando el error?
Mis informes, ¿es esta la información a la que hace referencia?
Entré y verifiqué que no tengo ningún campo nulo en la tabla de datos, sólo para ver si eso puede haber causado problemas.
@JustinNoe
Usted se divide fácilmente y lo hace automatizado en Power Query, consulte mi blog y video para obtener más información.
https://www.youtube.com/watch?v=O3AnAKjRBLM&t=0s
https://excelfort.com/allocate-amount-monthly-excel-powerquery/
________________________
Si mi respuesta fue útil, haga clic en Aceptarla como la solución para ayudar a otros miembros a encontrarla útil
Haga clic en el icono Thumbs-Up si le gusta esta respuesta 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |