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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Syndicate_Admin
Administrator
Administrator

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.

1 ACCEPTED SOLUTION
Igna
Resolver III
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

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
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

controlpvp
T10
T10
T10
T23
T24
T30
T41
T41
T41

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

Happy to hear 🙂

 

Can you mark this topic as solved ?

 

Best regards,

 

Igna

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
    )
)t1

Let's see if you can give me a hand.

Thank you.

Igna
Resolver III
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

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.