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
memasarif
New Member

Agregue filas si es el último día del mes y si está en días de la semana

Queridos todos,

Me gustaría sumar las filas para val si son el último día del mes y si están en los días de la semana. Si el último día del mes corresponde a sábado o domingo, sumar el viernes. ¿Cuál podría ser la fórmula? Necesito una fórmula general para agregar. Tengo varios meses en mi mesa.

Sí, gracias. lastday.png

1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hola @memasarif ,

Por favor, consulte la siguiente medida:

Measure =
VAR a =
    ADDCOLUMNS (
        SUMMARIZE (
            'Table',
            'Table'[Date],
            'Table'[Val],
            "weekday", WEEKDAY ( 'Table'[Date], 2 ),
            "weeknum", WEEKNUM ( 'Table'[Date] ),
            "eomonth", EOMONTH ( 'Table'[Date], 0 )
        ),
        "lastworkday",
            IF (
                'Table'[Date] = [eomonth],
                IF ( [weekday] <= 5, 1, 0 ),
                IF ( [weekday] = 5 && [weeknum] = WEEKNUM ( [eomonth] ), 1, 0 )
            )
    )
RETURN
    SUMX ( FILTER ( a, [lastworkday] = 1 ), 'Table'[Val] )

Para obtener más información, consulte el archivo pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ER3TmlaekNFKjActYx...

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Saludos

Dedmon Dai

View solution in original post

3 REPLIES 3
v-deddai1-msft
Community Support
Community Support

Hola @memasarif ,

Por favor, consulte la siguiente medida:

Measure =
VAR a =
    ADDCOLUMNS (
        SUMMARIZE (
            'Table',
            'Table'[Date],
            'Table'[Val],
            "weekday", WEEKDAY ( 'Table'[Date], 2 ),
            "weeknum", WEEKNUM ( 'Table'[Date] ),
            "eomonth", EOMONTH ( 'Table'[Date], 0 )
        ),
        "lastworkday",
            IF (
                'Table'[Date] = [eomonth],
                IF ( [weekday] <= 5, 1, 0 ),
                IF ( [weekday] = 5 && [weeknum] = WEEKNUM ( [eomonth] ), 1, 0 )
            )
    )
RETURN
    SUMX ( FILTER ( a, [lastworkday] = 1 ), 'Table'[Val] )

Para obtener más información, consulte el archivo pbix: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ER3TmlaekNFKjActYx...

Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Saludos

Dedmon Dai

Greg_Deckler
Super User
Super User

@memasarif - Pensar algo como:

Measure =
  VAR __Date = MAX([DATE])
  VAR __Table = 'Table'
  VAR __Table1
    ADDCOLUMNS(
      __Table,
      "FinalVal",
        SWITCH([DAY NAME]),
          "SUNDAY",SUMX(FILTER(__Table,[DATE]=__Date-2),[VAL]),
          "SATURDAY",SUMX(FILTER(__Table,[DATE]=__Date-1),[VAL]),
          [VAL]
        )
     )

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
sreenub
Resolver II
Resolver II

Por favor, encuentre a continuación Mesure para encontrar el saldo del último día laborable.
El último día de trabajo BalanceAmount ?
CALCULAR (
SUM ( Hecho[BalanceAmount] ),
FILTER ( DimDate, DimDate[Fecha] á MAX ( DimDate[Fecha] ) && DimDate[Weekdaynumber]<6)
)

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.