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

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.

Reply
Anonymous
Not applicable

No se puede agregar WEEKNUM([date]) cuando intento hacer que los números de semana estén por debajo de cada mes.

Estoy tratando de conseguir números de semana por mes, así que va,

Ene - 1,2,3,4

Feb - 1,2,3,4

Mar - 1,2,3,4,5

Así.

Encontré un DAX de https://community.powerbi.com/t5/Desktop/How-to-show-week-number-per-month/td-p/83607 y probé la solución de @v-micsh-msft, pero no le gusta el valor [date] en WEEKNUM() en la medida.

pbix.PNG

Puedo ver que el error dice que ocurre cuando la fórmula hace referencia a una columna que contiene muchos valores sin especificar una agregación como min, max, ect, que tengo en mi tabla DateKey.

¿Puede alguien decirme cómo puedo arreglarlo para usar el número de semana por mes?

<'Tabla DateKey' >

DateKey = 
VAR BaseCalendar = CALENDAR(min('All Tickets'[Created Date Time]), max('All Tickets'[Created Date Time]))
    RETURN
    GENERATE (
        BaseCalendar,
        VAR BaseDate = [Date]
        VAR YearDate = YEAR ( BaseDate )
        // VAR WeekNum = 1 + WEEKNUM(BaseCalendar) - WEEKNUM(STARTOFMONTH('All Tickets'[Created Date]))
        VAR MonthNumber = MONTH ( BaseDate )
        VAR YearMonthNumber = YearDate * 12 + MonthNumber - 1
        vAR YearWeek = WEEKDAY( BaseDate )
        RETURN ROW (
            "Day", BaseDate,
            "Year", YearDate,
            "Month Number", MonthNumber,
            "Month", FORMAT ( BaseDate, "mmmm" ),
            "Month Short", FORMAT( BaseDate, "mmm"),
            "Year Month Number", YearMonthNumber,
            "Year Month", FORMAT ( BaseDate, "mmm yy" ),
            "Year Month Short", FORMAT( BaseDate, "yyyy/mmm" ),
            "Week", FORMAT( BaseDate, "dddd"),
            "Week Short", FORMAT( BaseDate, "ddd"),
            "Week Number", WEEKNUM(BaseDate),
            "Quarter", "Q" & FORMAT( BaseDate, "Q"),
            "Year Quarter", FORMAT( BaseDate, "yyyy") & "/Q" & FORMAT( BaseDate, "Q"),
            "Datekey", FORMAT(BaseDate, "yyyymmdd")
        ))

Cualquier ayuda será apreciada.
Gracias de antemano!
2 REPLIES 2
lbendlin
Super User
Super User

Creo que inadvertidamente creaste una medida. Elimínelo y vuelva a crear como columna calculada.

Anonymous
Not applicable

Tienes razón. Estaba creando uno con medida, no columna.

¡Gracias!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.