Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gianmarco
Helper IV
Helper IV

Calculated column not working

Dear All,

I have the following calculated column:

 

var SUPPLIERS = CALCULATE(SUM(Cashflow[Importo (+/-)]),Cashflow[Source]=0, Cashflow[Categoria]="FORNITORI") 

var PREVISIONE_FORNITORI_CURRENT = Cashflow[Source]=5 && Cashflow[Completed_month]=0 && Cashflow[Par1]=1

var CLIENTS = CALCULATE(SUM(Cashflow[Importo (+/-)]),Cashflow[Source]=0, Cashflow[Categoria]="CLIENTI")

var PREVISIONE_CLIENTI_CURRENT = Cashflow[Source]=5 && Cashflow[Completed_month]=0 && Cashflow[Par1]=0

var PREVISIONALE_PAST = Cashflow[Source]=5 && Cashflow[Completed_month]=1

RETURN

IF( PREVISIONALE_PAST, 0, IF(PREVISIONE_FORNITORI_CURRENT, Cashflow[Importo (+/-)] - SUPPLIERS, IF(PREVISIONE_CLIENTI_CURRENT, Cashflow[Importo (+/-)] - CLIENTS, Cashflow[Importo (+/-)])))

 

Problem is the var in red do not works (it doesn't subtract anything).

Do you have any recommendations?
Thank you a lot

5 REPLIES 5
mlsx4
Super User
Super User

What do you want to calculate, the sum of importo when source is 0 or the category is "Fornitori"? In this case, you can try: var SUPPLIERS = CALCULATE(SUM(Cashflow[Importo (+/-)]), Cashflow[Source]=0 || Cashflow[Categoria]="FORNITORI"). 

 

Also check the type of data for both columns.

Actually I want to calculate the sum of importo when source is 0 and category is "Fornitori".

Is that a problem?

 

Change the "||" by "&&" operator. Anyway, your measure shouldn't be a problem.

I have checked with a simple example and it is working right

 

mlsx4_0-1688029247528.png

Try to check return SUPPLIERS. (Comment the two lines you have right now). If it computes the value, the problem is in your IF condition

 

Thanks @mlsx4

The problem is despite any operator I use, it does not subtract anything:

RETURN

IF( PREVISIONALE_PAST, 0, IF(PREVISIONE_FORNITORI_CURRENT, Cashflow[Importo (+/-)] - SUPPLIERS, IF(PREVISIONE_CLIENTI_CURRENT, Cashflow[Importo (+/-)] - CLIENTS, Cashflow[Importo (+/-)])))

 

Yes, but I think it is because of the if. Have you tried to return only Suppliers or Clients (without all the if)? Just as a way of checking the measure.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.