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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

calculating sum of sales based on max date

Hi Experts

 

i am trying to work out the sales based on the max date as a measure and following is not working

 

Measure = 

VAR _lastdate = max(all(table[peroddate]))
Return

Calculate[charged days],Filter('table,'table[peroddate] = _lastdate))

 

getting erro message the MAX function only accepts a column as a reference in a n argument.

6 REPLIES 6
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this:

Measure = 

VAR _lastdate = Calculate(max(table[peroddate]),all(table))
Return

Calculate([charged days],Filter('table,'table[peroddate] = _lastdate))

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

 

 

Anonymous
Not applicable

the issue is the date in the live connect in fact table is 1.11.21. where as the table in the power bi model has a max date or 1.10.21

Anonymous
Not applicable

Hi @Anonymous ,

In order to make troubleshooting and provide you a suitable solution, could you please share some raw data in your table with Text format , the formula of measure [charged days] and your expected result with calculation logic and special examples?

1. Raw data

yingyinr_0-1639563090876.png

2. The formula of measure [charged days]

 

charged days=calculate(count(xx),filter('table',xxx))

 

3. Expected result

Best Regards

amitchandak
Super User
Super User

@Anonymous , Try like

 

Measure =

VAR _lastdate = maxX(all(table) , table[peroddate]))
Return

Calculate[charged days],Filter('table,'table[peroddate] = _lastdate))

 

or

 

use

maxX(allselected(table) , table[peroddate]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

not working - sorry all, not getting the correct values for max date which is 01.10.21

Is [charged days] a measure? if yes, Can you share a code you used for [charged days]?

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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