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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Agreenwood
Helper I
Helper I

DAX - Using Filter to Sum All Months by Working Day

Hi,

 

Fairly new to DAX and been frustrated all day trying to figure this one out. There is probably a simple answer.

 

I have a 'Dates' table which has 2 columns: 1) 'Date' (2) 'Working Day' which holds the working day number of the month

 

I have a second table 'Revenue' which has 2 columns: 1) 'Date' (2) 'Daily Revenue'

 

There is a relationship between the two tables, on date.

 

I want to display in a report a filter on "Working Day", and a table/graph showing monthly revenue for all days up until the working day that is selected in the filter.

 

In Excel: =SUMIFS(Revenues[Revenue], Dates[Working Day], "<=" & SelectedWorkingDay)

 

In Power BI I have attempted many variations and combinations of failing measures, though my closest attempt is:

 

MtD Revenue = CALCULATE(SUM(Revenues[Revenue]), FILTER(ALL(Dates), Dates[workingday] <= MAX(Dates[workingday])))

 

However, this sums all revenue for all months before the selected working day, and does not sum the revenue for the individual month in the visualisation.

 

I have also attempted to use the EARLIER() function in a calculated column, though using this solution I can not use the working day filter on the dashboard.

 

Thank you in advance for your help... 

1 ACCEPTED SOLUTION

Hi @Agreenwood,

 

According to your formulas, it seems the monthly revenue will be accumulated. Maybe you can try these formula below. You can check it out in this file

Measure 2 =
TOTALYTD (
    SUM ( Revenues[Revenue] ),
    Dates[Date],
    FILTER ( ALL ( 'Dates' ), 'Dates'[WorkingDay] <= MAX ( Dates[WorkingDay] ) )
)
Measure =
TOTALMTD ( SUM ( Revenues[Revenue] ), 'Dates'[Date] )

DAX_Using_Filter_to_Sum_All_Months_by_Working_Day

 

Best Regards,

Dale

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

View solution in original post

2 REPLIES 2
Agreenwood
Helper I
Helper I

Ok, I think I may have answered my own question with the following measure:

 

MtD Revenue = CALCULATE(SUM(Revenue[Revenue]), FILTER(ALL(Dates), Dates[workingday] <= MAX(Dates[workingday])), FILTER(ALL(Dates), Dates[Date] <= MAX(Revenue[date])))

 

Are there any alternative ways of completing the same, or better ways maybe?

Hi @Agreenwood,

 

According to your formulas, it seems the monthly revenue will be accumulated. Maybe you can try these formula below. You can check it out in this file

Measure 2 =
TOTALYTD (
    SUM ( Revenues[Revenue] ),
    Dates[Date],
    FILTER ( ALL ( 'Dates' ), 'Dates'[WorkingDay] <= MAX ( Dates[WorkingDay] ) )
)
Measure =
TOTALMTD ( SUM ( Revenues[Revenue] ), 'Dates'[Date] )

DAX_Using_Filter_to_Sum_All_Months_by_Working_Day

 

Best Regards,

Dale

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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