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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SHAKEDALROY
Helper I
Helper I

Creación de una medida

Hola

Hice un cálculo en SQL.. y necesito convertirlo en una medida en Power BI.

En mi SQL tengo 3 tablas (FactParkingViolation,DimIssuer,DimIssuingAgency), cuando agregué las tablas a Power BI hice un megre entre las dos tablas - DimIssuer & DimIssuingAgency. así que ahora tengo dos tablas en Power BI -FactParkingViolation y DimIssuer.

No estoy tan familiarizado con Dax de esa manera que no sé cómo crear esta medida.

¡La ayuda se apreciará mucho!

Esta es la consulta SQL:

SELECT SUM(IssuingAgencyAverageYearlySalary)*0.03

DESDE(

SELECT DISTINCT(DI.IssuerID) ,IssuingAgencyAverageYearlySalary

DESDE FactParkingViolation FPV IZQUIERDA UNIRSE

DimIssuer POR FPV. IssuerKey á DI.IssuerKey

IZQUIERDA UNIRSE DimIssuingAgency DIA

ON.IssuingAgencyCode - DIA. IssuingAgencyCode

WHERE YEAR(IssueDate) á 2016 ) R

8 REPLIES 8
v-stephen-msft
Community Support
Community Support

Hola @SHAKEDALROY ,

¿Podría decirme si su problema ha sido resuelto?
Si es así, acédi es la solución. Más gente se beneficiará de ello.
O todavía está confundido al respecto, por favor proporcione más detalles sobre su tabla y su problema o compártame con su archivo pbix de su Onedrive for Business.


Saludos
Stephen Tao

v-stephen-msft
Community Support
Community Support

No @SHAKEDALROY ,

Usted podría leran la fusión de este enlace.

Después de fusionarse, pruebe esta medida.

CALCULATE(SUM('Table'[IssuingAgencyAverageYearlySalary]),FILTER('TABLE',YEAR([IssueDate]) á 2016))*0.03

Saludos

Stephen Tao

Si este post ayuda,entonces considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

AllisonKennedy
Super User
Super User

@SHAKEDALROY el DAX For esto es simple:

Medida salarial : SUM(FactParkingViolation[IssuingAgencyAverageYearlySalary])*0.03

O si lo quieres siempre para el año 2016:

SINTAXIS ACTUALIZADA:

Salary 2016 á SUMX(FILTER(FactParkingViolation, RELATED(Table[IssueDate]) - 2016), [IssuingAgencyAverageYearlySalary])*0.03)

El truco es crear las relaciones. No es necesario hacer la combinación si no desea, pero sí necesita crear relaciones en FPV. IssuerKey : DI.IssuerKey y DI.IssuingAgencyCode - DIA. IssuingAgencyCode

https://excelwithallison.blogspot.com/search?q=relationships


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hola @AllisonKennedy gracias por su respuesta,

Necesitaba hacer esa fusión para diferentes cálculos.. Traté de añadir 'relacionado' a la fórmula DAX que me escribiste pero todavía no funciona, ¿sabes cómo?

Gracias.

image.png

@SHAKEDALROY Parece que tienes un extra ) antes de la coma. Lo siento, eso fue mi culpa como lo fue en mi fórmula también. ¡Eso es lo que obtengo por escribir DAX a ciegas!


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

i think something is still missing @AllisonKennedy  /:

The result in SQL is 18,639,996

and when i tried your formula in Power BI the result is 451,796,281

¿Cómo has hecho la fusión? ¿Eliminó duplicados, el código SQL usa DISTINCT, que no hemos tenido en cuenta en el DAX. Además, es posible aumentar las filas en la combinación si no tiene cuidado. https://excelwithallison.blogspot.com/2020/10/merge-ahead-one-for-one.html


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

amitchandak
Super User
Super User

@SHAKEDALROY , Usted ha creado 1 - Muchas resiones entre las dimesiones y los hechos

DimIssuingAgency - FactParkingViolation, DimIssuer -FactParkingViolation , También se une a FactParkingViolation con la tabla de fechas que tiene año en IssueDate (Date[Date])

A continuación, puede agregar +0 en la medida que está creando para tener la unión izquierda

Para obtener lo mejor de la función de inteligencia del tiempo. Asegúrese de que tiene un calendario de fechas y que se ha marcado como la fecha en la vista de modelo. Además, únete a ella con la columna de fecha de tus hechos. Consulte :radacad sqlbi My Video Series Aprecia tus Felicitaciones.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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