Forum Discussion
Problem with measures aggregated on different dimensions
Hi everyone,
The metric is working fine with some atributes but not with one addicional date atribute (end_contract_date).
The definition of the metric is:
It works fine, if no attributes or dimensions are used, the metric gets the number of people from the last date of fact_date:
Total Person (Last fact_date)
it corresponds to the code:
The problem comes when entering another field, in this case the end of contract date (end_contract_date), which I have converted to string on source database to avoid other problems.
In this case, the metric doesn't work and when the fact_date date is not used, it gets values previous to the last fact_date date.
Values out of date_fact from Total_Person metric
This behavior is not valid. The metric should exclude data for end_contrac_date values '19991231' that corresponds to a date before (2019-11-30), only should gets data for the last date of fact_date (2019-12-31).
Could someone help me to solve the error? I have used this type of metric on various tables and they work correctly except from this metric. The HHRR table is not related to any table and is not a model problem.
1 Reply
- AnonymousNot applicable
I don't exactly yet understand the issue... but I can tell you that your model is not a good one. Please watch these to see how to create good, reliable and correct models:
Bear in mind that if you don't follow the Best Practices you'll be having bugs in your calculations without even realizing this. This is not a joke. Please read this to see what issues you can face:
https://www.sqlbi.com/articles/understanding-dax-auto-exist/
Also, please note that each and every sound, good model needs to have a DATE TABLE and slicing by columns of a fact table is strictly forbidden. Slicing can be only carried out through dimensions. You should have all columns in your fact tables HIDDEN.
Best
D