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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
hari_bi
Helper I
Helper I

How to Get fiscal year lastmonth value in DAX?

Fiscal Year Last Month value.PNG

 

The above one is my scenario , i need to show FiscalYear last moth value in Other column like "Sales2".

But Sales are caluated measure like "Sales := Actuals/totalcast ".

 

2 ACCEPTED SOLUTIONS

Hi @hari_bi,

You could create this measure:

Measure 4 = var a= MAXX(ALL('Date'),IF(ISBLANK([E_onHandsMonthsCover]),BLANK(),CALCULATE(MAX('Date'[Year Month]),ALLEXCEPT('Date','Date'[Year Month]))))
Return IF(ISBLANK([E_onHandsMonthsCover]),BLANK(),IF(MAX('Date'[Year Month])=a,[E_onHandsMonthsCover],CALCULATE([E_onHandsMonthsCover],FILTER(ALL('Date'),'Date'[Year Month]=a))))

Result:

1.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/lk9uvrpc3lf4d0q/Local%20Copy%20R%26D.pbix?dl=0

 

Regards,

Daniel He

Community Support Team _ Daniel He
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

Hi Daniel He,

 

Thanks for your replay , Its working as per my requirment.

 

But i did the same in tabular model live connection , but i am getting error like below:

"The function MAX takes an argument that evaluates to numbers or dates and cannot work with values of type String."

here i pass [MonthId] which is integer column.

I thik this will work.

 

Thank you for healping out to design DAX.

 

regards,

hari

View solution in original post

10 REPLIES 10
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @hari_bi,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a calculated column and you could see the result:

Sales2 = CALCULATE(SUM(Table1[Sales]),FILTER('Table1','Table1'[Fisacl Month]=MAX('Table1'[Fisacl Month])))

2.PNG

 

Regards,

Daniel He

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

Hi v-danhe-msft,

 

Thanks for your replay,

 

Here small update from my side.

 

Sales is Calcualted Measure not a column like Sales = A/B , here A is another Calcualted Measure and B is also Calcualted Measure and FiscalMoth column is avaialble in Date table not in the same table.

 

when i do sum, it will showing only available colums in a perticular table not able to find the Calcualted Measure.

 

I tried to change the formula like below but I am getting error in SUM() and Max() function are not accepting the Calcualted Measures.

 

Sales2 = CALCULATE(SUMX('Customer Depletions',FILTER('Customer Depletions',RELATED('Date'[Year Month]=
MAX(RELATED('Date'[Year Month]))))))

 

even i am not able to create Sales2 as a calculated column , Can you provide your suggestion on the above formula.

Hi @hari_bi,

Based on my test, I have create the sales as measure:

Sales measure = CALCULATE(SUM(Table1[Sales]))/1

And you could modify the former formula as:

Sales2 = CALCULATE([Sales measure],FILTER('Table1','Table1'[Fiscal Month]=MAX('Table1'[Fiscal Month])))

Now you could get the correct result.

1.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/ewivkb1cjypbt34/How%20to%20Get%20fiscal%20year%20lastmonth%20value%20in%20...

 

Regards,

Daniel He

 

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

Hi Daniel He,

 

I am sharing my PBI repeort with you can you create last moth value as new column.

Page name : Last month Sales , and as per my requirment data avaialbe in table visual.

 

Thanks in Advance.

 

like for PBI Report: https://drive.google.com/file/d/1ktOVLG7FzQbsnsX7h9GgZZ4qHcbioFZW/view

 

 

Regards,

Hari.

Hi @hari_bi,

I have no access to the pbix file, could you please give me the access to the file?

1.PNG

 

Regards,

Daniel He

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

Hi Daniel He,

 

Sorry for the inconveniance,

 

Can you check this path once , i thinks you can access the PBI report now.

https://www.dropbox.com/s/lnvnttc4tvmiq7k/Local%20Copy%20R%26D.pbix?dl=0

 

 

Thank you,

Hari.

 

Hi @hari_bi,

You could create this measure:

Measure 4 = var a= MAXX(ALL('Date'),IF(ISBLANK([E_onHandsMonthsCover]),BLANK(),CALCULATE(MAX('Date'[Year Month]),ALLEXCEPT('Date','Date'[Year Month]))))
Return IF(ISBLANK([E_onHandsMonthsCover]),BLANK(),IF(MAX('Date'[Year Month])=a,[E_onHandsMonthsCover],CALCULATE([E_onHandsMonthsCover],FILTER(ALL('Date'),'Date'[Year Month]=a))))

Result:

1.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/lk9uvrpc3lf4d0q/Local%20Copy%20R%26D.pbix?dl=0

 

Regards,

Daniel He

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

Hi Daniel He,

 

Thank you for your help to get last month value.

 

Small update on the same requirement , Please find the below tabale:

 

Index match.PNG

Now i have one more column "Reporting Month" added newly.

 

If Reporting Moth = Dec-17 , i need to search that "Dec-17" in Fiscal Month Column first then what ever the value for that month in "Months Cover" column ,  i need display the same value as new column.

 

Here i am sharing my PBI file for the same , present in PBI file data not available.

 

https://www.dropbox.com/s/nnw8mj12d3e2xj0/Month%20Match.pbix?dl=0

 

Thank you.

Hari

Hi Daniel He,

 

Thanks for your replay , Its working as per my requirment.

 

But i did the same in tabular model live connection , but i am getting error like below:

"The function MAX takes an argument that evaluates to numbers or dates and cannot work with values of type String."

here i pass [MonthId] which is integer column.

I thik this will work.

 

Thank you for healping out to design DAX.

 

regards,

hari

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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