cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bourne2000
Frequent Visitor

Calculating fiscal year using DAX function?

Hi

 

I have two tables one is a transaction and another one is a date table

 

The transaction table has two columns category, and amount. I have ten categories in the category table. I need to filter only three category. Date table has a date and year column.

 

I want to calculate the fiscal year (7/1/2017- 6/30/2018) using the DAX function.

 

Need output as below,

 

CategoryFiscal Year amount
B15000
C2000
D9000

 

When I use Filter for category and Date, I am able to get the above results. However, when I use the below DAX function, I am getting a different value as well as unable to filter the categories.

 

fiscial year= TOTALYTD(SUM(TRANSACTIONS[AMOUNT]), DATE[DATE], "6/30")
 
 
I need to use the Dax function for both filters and calculating fiscal year. Please advise.
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @bourne2000 

Not clear about your data model and table structure, so I create a sample, it may give you pointers. See sample file attached below.

-

Create a measure,

Measure = 
VAR _enddate=DATE(SELECTEDVALUE('Table'[fiscal year]),6,30)
var _firstdate = EDATE(_enddate,-12)
return 
CALCULATE(SUM(TRANSACTIONS[AMOUNT]),FILTER(TRANSACTIONS,TRANSACTIONS[DATE]<=_enddate&&TRANSACTIONS[DATE]>_firstdate))

Result:

v-xiaotang_2-1620969218158.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @bourne2000 

Not clear about your data model and table structure, so I create a sample, it may give you pointers. See sample file attached below.

-

Create a measure,

Measure = 
VAR _enddate=DATE(SELECTEDVALUE('Table'[fiscal year]),6,30)
var _firstdate = EDATE(_enddate,-12)
return 
CALCULATE(SUM(TRANSACTIONS[AMOUNT]),FILTER(TRANSACTIONS,TRANSACTIONS[DATE]<=_enddate&&TRANSACTIONS[DATE]>_firstdate))

Result:

v-xiaotang_2-1620969218158.png

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

amitchandak
Super User IV
Super User IV

@bourne2000 , This seems correct.

fiscial year= TOTALYTD(SUM(TRANSACTIONS[AMOUNT]), DATE[DATE], "6/30")

 

You will have YTD for each category. I think YTD will not sum up across category



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

@amitchandak  Fiscal year values are not matching when I use the Dax function. It's correct when I use date slicer. 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors