Balance Subcat nuevo = IF(and('BC:Movs_contabilidad'[4 DIGITOS]=5510||'BC:Movs_contabilidad'[4 DIGITOS]=5525,[Acumulado]<0),"3. Otras deudas a corto plazo",IF(and('BC:Movs_contabilidad'[4 DIGITOS]=5523||'BC:Movs_contabilidad'[4 DIGITOS]=5524,[Acumulado]<0),"Deudas con empresas del grupo y asociadas a corto plazo",'BC:Movs_contabilidad'[Balance-Subcategoría]))
Basically stating that if this 4 accounts have the "Acumulado" measure less than zero,they have to go to a liability subcategory,and if not, to assets (which is the standard for this accounts,since I put that in the conditional column I created before). I checked and it puts the correct category for each row of these accounts.
However,when I create the visual matrix, even if the "Acumulado" measure is less than 0, the accounts still go to the Assets, because the category and "Mass" were still in Assets (due to the conditional column). This is when the problems began,since when I replicated this formula to both of these categories, I got a "circular referency" error. After cheking a lot of tutorials, I thought I get the solution, by adding the ALLEXCEPT part in the Acumulado formula, creating an Index column and making it the primary key. With this, I didn´t get that error.
But,when I tried to create the matrix, I realized it didn´t aggregate the values of the accounts, instead it put in the Assets the aggregated rows in positive, and in Liabilities the same with negative rows.
Basically,either I get the correct level of aggregation but placed in the wrong "Mass",or I get the correct "Mass" but more desagregated,which doesn´t work for what I want since it creates a bigger total amount for categories that shouldn´t have that much.
I also tried to simply make the Subcategory formula and then link the category and subcategory with the columns of another table (that has these 3 categories),with this formula (since LOOKUPVALUE send me the "A table of multiple values was supplied where a single value was expected" error):
CALCULATE(FIRSTNONBLANK('BALANCE RESUMEN CATEGORIAS'[Column3],1),
FILTER(ALL('BALANCE RESUMEN CATEGORIAS'),'BALANCE RESUMEN CATEGORIAS'[Column1]='BC:Movs_contabilidad'[Balance Subcat nuevo]))
But still didn´t work (actually it messed for some reason the values a lot and not even the other accounts were right)
So, any ideas on how I can solve this and have the accounts´ values aggregated until the selected date,and depending on the value (less or more than 0),clasify them into the correct category,without having a "circular referency" error?