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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.