Forum Discussion
power bi function ALL strange behavior
- 1 year ago
first one is
Measure 2 = CALCULATE(COUNTA(Query1[target_lfs_agg.f_m_id]),ALL(Query1[target_lfs_agg.age_group]))
second one isMeasure 2 = CALCULATE(COUNTA(Query1[target_lfs_agg.f_m_id]),ALL(Query1[target_lfs_agg.age_group_id]))
the strange thing is that the result of the first image finally gave me a correct result when i included the (id) column which i used in sorting the description column with the all() functionMeasure 2 = CALCULATE(COUNTA(Query1[target_lfs_agg.f_m_id]),ALL(Query1[target_lfs_agg.age_group]),
ALL(Query1[target_lfs_agg.age_group_id]))
Hello !
Thank you for posting on Fabric community.
I think that the issue is about how Power BI is treating target_lfs_agg.age_group as a text column that is not truly disconnected from context. When you use ALL(Query1[target_lfs_agg.age_group]) thisis removes the filter only on that column. Power BI re-applies the visual-level context to show a bar per category even though the measure ignores the filter from the column itself.
Your second visualuses target_lfs_agg.age_group_id which is numeric, (I assumed that you use it as a surrogate key) and because it's an integer and doesn’t carry any internal display logic or metadata (like formatted labels), Power BI doesn’t re-apply as much context automatically, especially if it's not used elsewhere in visuals or sorting.
So you should try :
Measure 2 =
CALCULATE(
COUNTA(Query1[target_lfs_agg.f_m_id]),
REMOVEFILTERS(Query1[target_lfs_agg.age_group])
)
or Measure 2 =
CALCULATE(
COUNTA(Query1[target_lfs_agg.f_m_id]),
ALL(Query1)
)