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
Anonymous
Not applicable

Calculation in DAX measure returing all the rows.

Hi Everyone,

 

I created a measure using below query. Logic wise it is correct but the only thing I am facing right now is that It is returning all the rows from the table. What I observe is I am getting this output because in Var R1 and R2 I am doing some calculation. As you can see below i am adding 1 and also multiplying it with 10. This is applying to each row in the table. Can someone please let me know how should I write R1 and R2.

 

I also have a date slicer in the report page. where I am selecting only 1 date.

 

IndexBaseValue =
Var Mindate = CALCULATE(MIN(IndexFundNAV[Date]),ALL(IndexFundNAV[Date]))
Var Maxdate = CALCULATE(MAX(IndexFundNAV[Date]))
Var Currentdate = IF(Maxdate<Mindate,Mindate,Maxdate)
Var Diffdays = DATEDIFF(Mindate,Currentdate,DAY)
Var R1 = CALCULATE(10*(1+[RITD%]))
Var R2 = CALCULATE((10*(1+[RITD%]))^(Diffdays/365))

Var Result = if (Diffdays<365,R1,R2)

Return
Result

 

Example for desired output:

Date             IndexName IndexBaseValue

28-Sep-19     ABC             8.9

 

Currently getting:

Date             IndexName IndexBaseValue

28-Sep-19     ABC             10

28-Sep-19     ABC             10

28-Sep-19     ABC             10

28-Sep-19     ABC             8.9

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 REPLIES 2
Greg_Deckler
Super User
Super User

@Anonymous - A little difficult to tell what is going on, sample source data might help.

 

Check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks @Greg_Deckler  for your reply. I will check the links which you have shared. However my issue got resolved. There was some table relatioship issue was there because of  that the measure not returing the correct answer. 

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.