0

I am editing my question which I want exactly.

I have two columns Actual Units, Future Units from Fact A and Fact B respectively but at same granular level.I also have Demand Units from Fact B

My requirement is :

1. Projected Units = Coalesce(Actual Units,Future Units)    
2. Stock Units = IF(Projected Units > Demand Units,Demand Units,Projected 
Units)
3. Stock Rate = (Stock Units/Demand Units)    

enter image description here

I cannot join the two facts in the data source view level and do the
calculation there because they are a very huge tables, so I think the performance would be very slow. If you say that doing the calculations at the data source view level level is the only way we have, please let me know.

Did you get this?

L Y E S - C H I O U K H
  • 4,765
  • 8
  • 40
  • 57
Krish Dev
  • 13
  • 5

1 Answers1

0

When calculating the grand total MDX is summing up A, summing up B, and then comparing them.

If you want the calculation to occur at the row level (checking whether B>A) then edit the Data Source View and add a new calculated column to the table your measure group is based upon. The calculated column should be:

CASE WHEN B>A THEN A ELSE B END

Then create a Sum measure based upon that new column.

This approach will perform much better compared to any completely MDX approach to calculating this at a very detailed grain. If your fact tables had 500,000 rows or less and you had a degenerate Dimension which was the same grain as the grain you need to calculate at, we could possibly do it in MDX. But since you are concerned with SQL query performance I am assuming the tables are big. Just remember that SQL is done once at processing time. MDX is calculated in every query at query time. So do expensive things in SQL when you can.

GregGalloway
  • 11,355
  • 3
  • 16
  • 47
  • Thankyou,this works.But my column A is also a derived column from another measure.So it is also a calculated measure.Is there any other way for this? – Krish Dev Mar 20 '18 at 13:39
  • Greg..I have edited the requirement above exactly I need.please have a look. – Krish Dev Mar 20 '18 at 21:17