The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hello,
I need to create a measure to subtract two rows from the same column based on different dates. The first value needs to be the selected on the slicer and the second one is always December.
I've tried this way but it's not working. The measure returns the first value based on the slicer and the second returns the value of December, but when together the subtraction doesn't work.
Medida =
VAR mes = SELECTEDVALUE(tabela_data[Mês],0)
Return
CALCULATE(sum(Cockpit[Valor]), Cockpit[Indicador]="FCF ACT YTD",tabela_data[Mês]=mes) CALCULATE(sum(Cockpit[Valor]),Cockpit[Indicador]="FCF OAG YTD",tabela_data[Mês]=12)
I've also tried replacing the variable "mes" for "4" at the first calculate just to see if it works and it does. So I think the issue is related to the use of a variable with a subtraction
Help, please.
Best regard.
Solved! Go to Solution.
Oi @Anonymous ,
Tenta a formula de dezembro assim:
CALCULATE(sum(Cockpit[Valor]), FILTER(ALL(tabela_data), Cockpit[Indicador]="FCF OAG YTD",tabela_data[Mês]=12))
Você precisa ignorar o filtro de data aplicado, caso contrário você não tem nenhum retorno.
Not that, I forgot it here, but I have it on the measure.
Oi @Anonymous ,
Tenta a formula de dezembro assim:
CALCULATE(sum(Cockpit[Valor]), FILTER(ALL(tabela_data), Cockpit[Indicador]="FCF OAG YTD",tabela_data[Mês]=12))
Você precisa ignorar o filtro de data aplicado, caso contrário você não tem nenhum retorno.
With some adjustments this solution works fine.
I just needed to implement a Filter(ALL()) to all the criteria that I want.
Final result:
@Anonymous ,
Não sei como você está fazendo o visual, porém talvez não seja necessário aplicar o filtro no valor atual da linha, apenas no anterior, o proprio SUM(VALOR) já vai fazer isso por você. Isso evita sobrecarga, e só vai sentir se seu modelo tem uma grande quantidade de dados.
ola,
Não funciona porque dá erro de sintaxe. Não posso trazer a coluna Cockpit[Indicador] para dentro do Filter porque no All invoco a tabela_data.
Já tentei por o filtro da Cockpit[Indicador] de fora e fazer dois FILTER, mas tambem não funciona, está-me a devolver um valor que nem sei onde está a ir buscar agora.
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
20 | |
12 | |
10 | |
7 |