Forum Discussion
SQL to DAX
- 6 years ago
MaiconM1 , OK I put this together but I don't have the logic quite right. Can you explain the intent of your SQL in plain language?
PBIX is attached.
Measure = VAR __Table = FILTER( 'contas', MAX(contas[codplaco]) = "IPN001" && MAX(contas[databert]) >= DATE(2019,12,15) && "00902001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]) && NOT("00103001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio])) || NOT("00000501" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio])) ) RETURN IF(COUNTROWS(__Table) > 0,1,BLANK()) - 6 years ago
So close the first time! MaiconM1 PBIX is attached.
Measure = VAR __Table = FILTER( 'contas', MAX(contas[codplaco]) = "IPN001" && MAX(contas[databert]) >= DATE(2019,12,15) && "00902001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]) && (NOT("00103001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio])) || NOT("00000501" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]))) ) RETURN IF(COUNTROWS(__Table) > 0,1,BLANK())
MaiconM1 , OK I put this together but I don't have the logic quite right. Can you explain the intent of your SQL in plain language?
PBIX is attached.
Measure =
VAR __Table =
FILTER(
'contas',
MAX(contas[codplaco]) = "IPN001" &&
MAX(contas[databert]) >= DATE(2019,12,15) &&
"00902001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]) &&
NOT("00103001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio])) ||
NOT("00000501" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]))
)
RETURN
IF(COUNTROWS(__Table) > 0,1,BLANK())Hello Greg_Deckler.
The command will serve to find "numconta" that have "lancamen" with "codproprio" = 00902001, but do not have "lancamen" = 00103001 and 00000501
Today I use Grafana to do this monitoring, but I want to use Power BI
- Greg_Deckler6 years agoCommunity Champion
So close the first time! MaiconM1 PBIX is attached.
Measure = VAR __Table = FILTER( 'contas', MAX(contas[codplaco]) = "IPN001" && MAX(contas[databert]) >= DATE(2019,12,15) && "00902001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]) && (NOT("00103001" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio])) || NOT("00000501" IN SELECTCOLUMNS(RELATEDTABLE(lancamen),"__codproprio",[codproprio]))) ) RETURN IF(COUNTROWS(__Table) > 0,1,BLANK())- MaiconM16 years agoFrequent Visitor
That's right, thank you Greg_Deckler
I will do some tests, any questions I post a new question.
- Greg_Deckler6 years agoCommunity Champion
MaiconM1 That may not be the best/most efficient manner of doing that, I was hacking it together trying to interpret your SQL code as I went so just let me know!!