Forum Discussion
query mysql to DAX
Hello
How do I move this MySQL query to Power BI DAX?
SELECT COUNT(total) AS Contador, Sum(cantidad) as canti FROM (SELECT COUNT(*) AS total,sat_reparacion.cantidad FROM sat_reparacion INNER JOIN sat_lineas ON sat_reparacion.codigo_reparacion=sat_lineas.documento GROUP BY sat_lineas.documento HAVING (SUM(sat_lineas.pvp)=0)) ";
Thank you.
Hello,
Not sure of what you are trying to achieve doing this but :
Contador = COUNTROWS( FILTER( SUMMARIZE( FILTER( sat_reparacion, CALCULATE(SUM(sat_lineas[pvp])) = 0 ), sat_lineas[documento], "Contador", COUNTROWS(sat_reparacion), "canti", SUM(sat_reparacion[cantidad]) ), [Contador] > 0 ) )Igna
4 Replies
- Igna
Resolver III
Hello,
Not sure of what you are trying to achieve doing this but :
Contador = COUNTROWS( FILTER( SUMMARIZE( FILTER( sat_reparacion, CALCULATE(SUM(sat_lineas[pvp])) = 0 ), sat_lineas[documento], "Contador", COUNTROWS(sat_reparacion), "canti", SUM(sat_reparacion[cantidad]) ), [Contador] > 0 ) )Igna
- Syndicate_Admin
Administrator
It's perfect! Thank you
The explanation of what I wanted is:
I've got these two boards
Table of Controls
control T1 T2 T3 T4 T5 Table of Lines Controls
control pvp T1 0 T1 0 T1 0 T2 3 T2 4 T3 0 T4 1 T4 1 T4 1 As you can see, control T1, the sum of pvp in the table lines controls is 0, control T3 also adds 0, so the expected result I would want would be 2, since controls with 0 are 2
Anyway, with the previous measure it has worked perfectly for me.
Best regards
- Igna
Resolver III
Happy to hear 🙂
Can you mark this topic as solved ?
Best regards,
Igna
- Syndicate_Admin
Administrator
Sorry
I have a similar query but I'm not able to get it in DAX. The new query is:
SELECT COUNT(total) AS Contador FROM ( SELECT COUNT(*) AS total FROM sat_reparacion INNER JOIN sat_lineas ON sat_reparacion.codigo_reparacion=sat_lineas.documento WHERE ( no_reparable=0 OR no_reparable IS NULL ) AND ( garantia = 0 OR GARANTIA IS NULL ) GROUP BY sat_lineas.documento HAVING (SUM(sat_lineas.pvp)=0 ) )t1Let's see if you can give me a hand.
Thank you.