cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Sarencibia
Frequent Visitor

FROM SQL TO DAX

Hi!

 

I need help!!!

 

This is my query SQL:

Select (a.cump * 100 / a.total) as perc_error
from (
Select (
Select Count(*)
from adm.event ev
where ev.feature = 'KPIS'
and ev.id in (
Select da.event_id
from adm.data da
where da.feature = 'KPIS'
and da.jhi_type = 'VALID_WEIGHT'
)
and (ev.params like '%tipo=Pedido%' or ev.params like '%tipo=Contenedor%')
) as cump,
(
Select Count(*)
from adm.event ev
where ev.feature = 'KPIS'

) as total
) a;

 

And my DAX:

%perc_error= IF(ISBLANK(DIVIDE([number error],CALCULATE(COUNTROWS(dim_event),FILTER(dim_event,dim_event[feature]="KPIS")),0)),0,DIVIDE([number error],CALCULATE(COUNTROWS(dim_event),FILTER(dim_event,dim_event[feature]="KPIS")),0))

 

But it doesn't work properly, can you help me?

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Sarencibia 

You can try to create a measure like this:

Test =
VAR _total =
    COUNTROWS ( FILTER ( ALL ( 'adm.event' ), 'adm.event'[feature] = "KPIS" ) )
VAR _event_id =
    FILTER (
        ALL ( 'adm.data' ),
        'adm.data'[feature] = "KPIS"
            && 'adm.data'[jhi_type] = "VALID_WEIGHT"
    )
VAR _cump =
    COUNTROWS (
        CALCULATETABLE (
            FILTER (
                ALL ( 'adm.event' ),
                'adm.event'[feature] = "KPIS"
                    && 'adm.event'[id] IN _event_id
            ),
            CONTAINSSTRINGEXACT ( 'adm.event'[params], "tipo=Pedido" )
                || CONTAINSSTRINGEXACT ( 'adm.event'[params], "tipo=Contenedor" )
        )
    )
RETURN
    DIVIDE ( _cump * 100, _total )

 

If it dosen't work ,you can provide us with your special sample data (without sensitive data) so that we can help you better.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @Sarencibia 

You can try to create a measure like this:

Test =
VAR _total =
    COUNTROWS ( FILTER ( ALL ( 'adm.event' ), 'adm.event'[feature] = "KPIS" ) )
VAR _event_id =
    FILTER (
        ALL ( 'adm.data' ),
        'adm.data'[feature] = "KPIS"
            && 'adm.data'[jhi_type] = "VALID_WEIGHT"
    )
VAR _cump =
    COUNTROWS (
        CALCULATETABLE (
            FILTER (
                ALL ( 'adm.event' ),
                'adm.event'[feature] = "KPIS"
                    && 'adm.event'[id] IN _event_id
            ),
            CONTAINSSTRINGEXACT ( 'adm.event'[params], "tipo=Pedido" )
                || CONTAINSSTRINGEXACT ( 'adm.event'[params], "tipo=Contenedor" )
        )
    )
RETURN
    DIVIDE ( _cump * 100, _total )

 

If it dosen't work ,you can provide us with your special sample data (without sensitive data) so that we can help you better.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors