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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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 II
Resolver II

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

3 REPLIES 3
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

Igna
Resolver II
Resolver II

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.