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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
memasarif
New Member

Add rows if it is the last day of the month and if it is in weekdays

Dear All,

 

I would like to sum the rows for val if they are last day of the month and if they are in the weekdays. If last day of the month corresponds to either saturday or sunday then sum friday. What could be the formula? I need e general formula to add. I have several months in my table.

 

Thank you.lastday.png 

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

Hi @memasarif ,

 

Would you please refer to the measure below:

 

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] )

 

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ER3TmlaekNFKjActYx...

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

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

Hi @memasarif ,

 

Would you please refer to the measure below:

 

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] )

 

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/ER3TmlaekNFKjActYx...

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

Greg_Deckler
Community Champion
Community Champion

@memasarif - Thinking something like:

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]
        )
     )


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Please find below Mesure to find last working day balance .
 
Last workinng day BalanceAmount =
CALCULATE (
SUM ( Fact[BalanceAmount] ),
FILTER ( DimDate, DimDate[Date] = MAX ( DimDate[Date] ) && DimDate[Weekdaynumber]<6)
)

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors