Forum

Notifications
Clear all

Power Pivot

6 Posts
2 Users
0 Reactions
56 Views
(@andreaies)
Posts: 4
Active Member
Topic starter
 

I have a power pivot to with daily sales tables and date reference table. The user inputs the date and I need to add a column that calculate the sales to that date. The date is refreshing to the date reference table and my formula is:

=if(Sales_report_[Doc_Date]<=RELATED('Date Reference'[Date]),Sales_report_[Gross Sales],0)

So in the above I need gross sales amount to show if the date of the sales (Doc_Date) is less or equal to the date on the reference table (Date Reference'[Date]); otherwise, show 0. 

 

It is working but only shows gross sales for the dates within the same month. In other words, if the date reference is 02/28/2019 then it shows gross sales only for the rows within February 2019 but not January 2019. It is like not including the entire month in the if formula. 

 
Posted : 09/05/2020 3:55 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Andrea,

Remember DAX measures also use row and column context to filter. Do you have any month/date fields in the PivotTable that could be applying the filter to only show February data?

Mynda

 
Posted : 09/05/2020 8:16 pm
(@andreaies)
Posts: 4
Active Member
Topic starter
 

Yes, I'm comparing to a date. The data model has a date reference table that populates from the user input on the spreadsheet. 

 

=if(Sales_report_[Doc_Date]<=RELATED('Date Reference'[Date]),Sales_report_[Gross Sales],0)

 

The formula is looking to the 'Date Reference'[Date] table.  

 
Posted : 12/05/2020 9:01 am
(@andreaies)
Posts: 4
Active Member
Topic starter
 

The formula is working. However, it will only give me the rows for the same month. In other words, it will show only April for example if the date reference= 04/30/2020 but the formula is to show less or equal to April 30, 2020 so I'm expecting January 1 thru April 30th to show.  

 
Posted : 12/05/2020 10:13 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Andrea,

You haven't answered my question. I asked what fields you have in your PivotTable that contain a date. It would help if you shared your file or at least some screenshots.

Mynda

 
Posted : 13/05/2020 7:12 am
(@andreaies)
Posts: 4
Active Member
Topic starter
 

attached file with screenshots. 

 
Posted : 13/05/2020 12:02 pm
Share: