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
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
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.