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
LS1700
Resolver I
Resolver I

Sum sales for a specific point in time

Hello,

 

I have a table with dates and sales. I would like to present on a chart or on a table, the sales by month, however if the month equals the latest month available in the data, then it should display the data from the previous month.

  

 

 

 

Formula:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(all(Table1),(Table1[Date])=EOMONTH(MAX(Table1[Date]),IF(CALCULATE(MAX(Table1[Date]))=CALCULATE(MAX(Table1[Date]),ALL(Table1)),-2,-1))+1))

 

Displaying the measure on a table, this is what it looks like: as you can see the problem is in the first row. it should display 2:

Date              Sales       Measure

7/1/2017        1            (empty)

6/1/2017        2               2

5/1/2017        3               3

4/1/2017        4               4

3/1/2017        5               5

2/1/2017        6               6

1/1/2017        7               7

 

 

Does anyone have an idea how to solve this?

 

thanks

LS

1 ACCEPTED SOLUTION
LS1700
Resolver I
Resolver I

Solution:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1[Date]),CALCULATE(max(Table1[Date]))=EOMONTH((MAX(Table1[Date])),IF((MAX(Table1[Date]))=CALCULATE(MAX(Table1[Date]),ALL(Table1)),-2,-1))+1))

 

 

View solution in original post

1 REPLY 1
LS1700
Resolver I
Resolver I

Solution:

Measure = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1[Date]),CALCULATE(max(Table1[Date]))=EOMONTH((MAX(Table1[Date])),IF((MAX(Table1[Date]))=CALCULATE(MAX(Table1[Date]),ALL(Table1)),-2,-1))+1))

 

 

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.