Forum Discussion
Problem with granularity
Hi mlsx4 ,
I tried different approaches for this case..and hope I catched it right concersing your discription.
I had to tweek a bit with model and measures.
Actually I get following result:
- Assuming real rate data comes daily and theretical rate data random -> Real Rate table is my Fact table
- LookUp for theoretical rates (calculated column)
- works for each single Code (conserning your Screen above)
-----------------------------------------
Is this about the expected result?
Regards
- sergej_og3 years ago
Super User
Hey mlsx4 ,
glad to hear.
I will try to leave you an understandable description here.
-------------------------------------------------
1. I created a calculated column in "real rate" table (my fact table) to fetch theoretical rates.
Result:Formula:
LookUp_Theo_rate = LOOKUPVALUE( 'Theo rate Table'[Theor. Rate], 'Theo rate Table'[YearMonth], 'REAL rate Table'[YearMonth], 'Theo rate Table'[Code], 'REAL rate Table'[Code], 'Theo rate Table'[Category], 'REAL rate Table'[Category])
Can you pls try to achieve similar result.
When I drop these 2 fields into my table it looks like this:2. To fill the gaps I used this formula:
Last non blank Theo_rate = VAR Last_non_blank_date = CALCULATE( MAX('REAL rate Table'[YearMonth]), FILTER( ALL('REAL rate Table'), 'REAL rate Table'[YearMonth] <= MAX('REAL rate Table'[YearMonth]) && 'REAL rate Table'[LookUp_Theo_rate] <> BLANK() ) ) //this part will give you the MAX non blank date VAR Last_non_blank_Value = CALCULATE( SUM('REAL rate Table'[LookUp_Theo_rate]), FILTER( ALL('REAL rate Table'), 'REAL rate Table'[YearMonth] = Last_non_blank_date), FILTER( ALL('REAL rate Table'), 'REAL rate Table'[Code] = SELECTEDVALUE('REAL rate Table'[Code])), 'REAL rate Table'[Category] = SELECTEDVALUE('REAL rate Table'[Category]) ) RETURN IF( HASONEVALUE('Calendar'[Date]) && [Theor_] <> BLANK(), [Theor_], Last_non_blank_Value)Try to apply this piece of code into your model.
I cross my fingers.
I hope I could transfer this well to your case.
This formula gave me this result:
----------------------------
Regards