Forum Discussion
Dax help
- Anonymous4 years ago
Hi Anonymous
Here I will explain to you based on your screenshoot and your code.
From your screenshot we know [Margin] is a measure, you couldn't add a measure into sum. You want to get sum of [Margin] in YTD. Try sumx function.
[Margin] is based on [Weighted Average Yield] and [Weighted Average COF]. You need to add table name which you used in [Weighted Average Yield] and [Weighted Average COF] in Sumx.
sumx("Data Table Name Used in two basic measures",[Margin])2. TotalYTD is a time intelligence function in Dax code, it's format is as below.
Measure = TOTALYTD(<expression>,<dates>[,<filter>][,<year_end_date>])Please make sure Detail table is a date table with continous date in it. Details[Go Live] column should be a date column.
Make Sure the table you used to calculate [Weighted Average Yield] and [Weighted Average COF] has relationship with Detail table.
Totak spread YTD = TOTALYTD(SUMX('Table',[Margin]),Detail[Go Live])I build a sample, in my sample key measure table is my data table.
Relationship:
Measures:
Weighted Average Yield = AVERAGE('Key Measure'[Value1])Weighted Average COF = AVERAGE('Key Measure'[Value2])Margin = [Weighted Average Yield] - [Weighted Average COF]Totak spread YTD = TOTALYTD(SUMX('Key Measure',[Margin]),Detail[Go Live])Result:
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please send the Expresision used in Margin and teh screenshot of your datamodel.
This might cause beacuse the Measure Margin that is created does not have association with Detail table.
- ZikoPowerBI4 years agoHelper II
There is no relation between key Meaures table and Details table ,
ou have to either give the relation of details table in the dax or connect it.