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.
Hello guys, I'm trying to convert from positive to negative in a measure when a certain filter is applied:
Fact. Acumulado =
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL];1)=FIRSTNONBLANK(Dim_agencia[Agencia];1);
SUM('Table'[FACTURACION])*-1;
SUM('Table'[FACTURACION])
);
FILTER(
'Table';
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia];1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia];1))
);
SAMEPERIODLASTYEAR(DATESYTD(Calendario[Date]))
)
The thing is the measure is working partiallty because inside the table it shows the correct results but it doesn't for the grand total:
I'm not sure why, but it might be because for the grand total is applying the "ELSE" condition from the IF Function?
Solved! Go to Solution.
Hi, @Anonymous
You may modify the measures as below.
Fact. Acumulado =
SUMX(
DISTINCT('Table'[ANUNCIANTE]),
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL],1)=FIRSTNONBLANK(Dim_agencia[Agencia],1),
SUM('Table'[FACTURACION])*-1,
SUM('Table'[FACTURACION])
),
FILTER(
'Table',
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia],1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia],1))
),
SAMEPERIODLASTYEAR(DATESYTD(Calendario[Date]))
)
)
Fact. año completo =
SUMX(
DISTINCT('Table'[ANUNCIANTE]),
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL],1)=FIRSTNONBLANK(Dim_agencia[Agencia],1),
SUM('Table'[FACTURACION])*-1,
SUM('Table'[FACTURACION])
),
FILTER(
'Table',
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia],1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia],1)
)
),
PARALLELPERIOD(Calendario[Date],-1,YEAR)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , like
Fact. Acumulado =
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL];1)=FIRSTNONBLANK(Dim_agencia[Agencia];1);
SUM('Table'[FACTURACION])*-1;
SUM('Table'[FACTURACION])
);
FILTER(
'Table';
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia];1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia];1))
);
SAMEPERIODLASTYEAR(DATESYTD(Calendario[Date]))
;values('Table'[ANUCIANTE])
)
or an ew measaure on top of last one
new Fact. Acumulado =
sumx(summarize( 'Table', 'Table'[ANUCIANTE],"_1",[Fact. Acumulado]),[_1])
Hi @amitchandak
Neither of the results is working. The first one just gives me the same result I was getting before, the other one is blank. But I get it's hard to make it work without any data.
Since the data inside it's just for testing I uploaded the PBIX in case anyone want to test if can make that work.
Download the pbix
Thank you!
Hi, @Anonymous
You may modify the measures as below.
Fact. Acumulado =
SUMX(
DISTINCT('Table'[ANUNCIANTE]),
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL],1)=FIRSTNONBLANK(Dim_agencia[Agencia],1),
SUM('Table'[FACTURACION])*-1,
SUM('Table'[FACTURACION])
),
FILTER(
'Table',
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia],1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia],1))
),
SAMEPERIODLASTYEAR(DATESYTD(Calendario[Date]))
)
)
Fact. año completo =
SUMX(
DISTINCT('Table'[ANUNCIANTE]),
CALCULATE(
CALCULATE(
IF(
FIRSTNONBLANK('Table'[AGENCIA_ORIGINAL],1)=FIRSTNONBLANK(Dim_agencia[Agencia],1),
SUM('Table'[FACTURACION])*-1,
SUM('Table'[FACTURACION])
),
FILTER(
'Table',
'Table'[AGENCIA_ORIGINAL]=FIRSTNONBLANK(Dim_agencia[Agencia],1) || 'Table'[AGENCIA_MODIFICADA]=FIRSTNONBLANK(Dim_agencia[Agencia],1)
)
),
PARALLELPERIOD(Calendario[Date],-1,YEAR)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |