Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Manejo de minigráficos en un período de tiempo específico y cómo aumentar el ancho del minigráfico

Hola a todos,

He implementado minigráficos en la tabla de matrices para datos históricos como años, ahora estoy tratando de reproducirlo pero como base mensual (últimos 12 meses) para un KPI específico, pero no puedo seleccionar un período de tiempo (12 últimos meses) para DateTable como SUMMARIZE no maneja la variable de tabla si filtré en dax; también no puedo ampliar el ancho del minigráfico, siempre permanece como cuadrado estático svg. Aquí adjuní mi código dax, ¿podría alguien bueno en dax ayudarme?.

Gracias de antemano

Sparkline = 
var LineColor = "#363636"
var FillColor = "#E0E0E0"
var MaxDotColor = "#649398"
var MinDotColor = "#D9655D"
var FirstDotColor = "#363636"
var LastDotColor = "#363636"
var NumOfDashes =0
var DataPointPoint = distinctcount(DateTable[Date-Month])
var StrokeWidth = 
    switch(           
        TRUE(),
        DataPointPoint>24,3,
        DataPointPoint>12,4,
        5
    )
var CircleSize = 
    switch(
        TRUE(),
        DataPointPoint>24,8,
        DataPointPoint>12,9,
        10
    )
var ViewboxOffset = 
    switch(
        TRUE(),
        DataPointPoint>24,-8,
        DataPointPoint>12,-9,
        -10
    )
var XMinDate = MIN(DateTable[Date-Month])
var XMaxDate = MAX(DateTable[Date-Month])

var YMinValue=minx(values(DateTable[Date-Month]),calculate([KPI Last 12]))
var YMaxValue=maXx(values(DateTable[Date-Month]),calculate([KPI Last 12]))

var SparklineTable = ADDCOLUMNS(
    SUMMARIZE(DateTable,DateTable[Date-Month]),
        "X",INT(100*DIVIDE(DateTable[Date-Month]-XMinDate,XmaxDate-XminDate)),
        "Y",INT(100*DIVIDE([KPI Last 12]-YMinValue,YmaxValue-YminValue)))

var Lines = CONCATENATEX(SparklineTable,[X] & "," & 100 - [Y]," ",[Date-Month])

var MaxSparkYValue = maxx(SparklineTable,100 - [Y])
var MaxSparkXValue = maxx(filter(SparklineTable,[Y] = MaxSparkYValue),[X])
var MinSparkYValue = minx(SparklineTable,100 - [Y])
var MinSparkXValue = minx(filter(SparklineTable,[Y] = MinSparkYValue),[X])

var FirstSparkYValue = minx(filter(SparklineTable,[Date-Month]=XMinDate),[Y])
var FirstSparkXValue = minx(filter(SparklineTable,[Date-Month]=XMinDate),[X])
var LastSparkYValue = maxx(filter(SparklineTable,[Date-Month]=XMaxDate),[Y])
var LastSparkXValue = maxx(filter(SparklineTable,[Date-Month]=XMaxDate),[X])

var url = 
    "data:image/svg+xml;utf8," & 
    "<svg xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' viewBox='0 " & ViewboxOffset & " 100 120'>" &
    "<polyline 
    fill='"& FillColor  & " '
    stroke='"& LineColor  & " '
    stroke-width='"& StrokeWidth & " '
    stroke-linecap='round' 
    stroke-linejoin='round' 
    stroke-dasharray='"& NumOfDashes & "'
    points='"& Lines  &
    "'/>" &
    "<circle cx='"& FirstSparkXValue & "' cy='" &100 -FirstSparkYValue & "' r='" & CircleSize & "' fill='" & LastDotColor &"' />" &
    "<circle cx='"& LastSparkXValue & "' cy='" &100 -LastSparkYValue & "' r='" & CircleSize & "' fill='" & LastDotColor &"' />" &
    "<circle cx='"& MaxSparkXValue & "' cy='" &100 -MaxSparkYValue & "' r='" & CircleSize & "' fill='" & MaxDotColor &"' />" &
    "<circle cx='"& MinSparkXValue & "' cy='" &100 -MinSparkYValue & "' r='" & CircleSize & "' fill='" & MinDotColor &"' />" &
    "</svg>"
return url
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @K_Caballero16 ,

por favor, compruebe si estos enlaces están proporcionando lo que está buscando

Si no es así, considere la posibilidad de crear un pbix que contenga datos de ejemplo pero que refleje su modelo de datos, cargue el pbix en onedrive o dropbox y comparta el enlace.

Con suerte, esto le proporcionará lo que está buscando, al menos proporcionar algunas nuevas ideas.

saludos
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

1 REPLY 1
TomMartens
Super User
Super User

Hey @K_Caballero16 ,

por favor, compruebe si estos enlaces están proporcionando lo que está buscando

Si no es así, considere la posibilidad de crear un pbix que contenga datos de ejemplo pero que refleje su modelo de datos, cargue el pbix en onedrive o dropbox y comparta el enlace.

Con suerte, esto le proporcionará lo que está buscando, al menos proporcionar algunas nuevas ideas.

saludos
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors