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
Anonymous
Not applicable

Cambiar SQL a DAX

Hola.
Tengo estas 2 cláusulas SQL que necesito usar en la medida PowerBI.

Este necesito añadir decimales - Rivisumma alv 0% á SUMX ( 'ol', [price] * ( [quantity] ) / (1 + [alv] /100))
Así es como lo hago en SQL, pero no he encontrado cómo hacerlo en DAX.
SELECT ROUND(SUM(ol.quantity * ol.price / (1 + CAST(ol.alv AS DECIMAL(10, 6)) / 100)), 2) Summa


Y este he probado varias declaraciones IF en DAX, pero nada está funcionando. Si ol.price es superior a 0, sume ol.quantity. Si ol.price está por debajo de 0, entonces disminuya de ol.quantity.


Gracias por ayudar con esto.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@HeiJoe , Probar como

round(SUMX ( 'ol',divide( [price] * ( [quantity] )*1.0 ,(1 + [alv] /100.0))),2)

SUMX('ol' , Switch(True(), ol[price] > 0 , ol[quantity] , ol[price] < 0 , -1* ol[quantity] , 0 ))

View solution in original post

3 REPLIES 3
hemantsingh
Helper V
Helper V

Prueba así en DAX -

Rivisumma alv 0% á SUMX ( 'ol', [price] * ( [quantity] ) / (1 +  [alv] /100))

Rivisumma alv 0% ?
VAR A - SUMX ( 'ol', [price] * ( [quantity] )
VAR B a 1+ Divide([alv],100,0)
devolución
Dividir(A,B)

Measure_2 de la casa de los
Switch(True(),

ol.price >0, sum(ol.quantity),

ol.price < 0, escriba la compilación aquí como arriba,
0
)


espero que esto ayude.

saludos

Hemant

amitchandak
Super User
Super User

@HeiJoe , Probar como

round(SUMX ( 'ol',divide( [price] * ( [quantity] )*1.0 ,(1 + [alv] /100.0))),2)

SUMX('ol' , Switch(True(), ol[price] > 0 , ol[quantity] , ol[price] < 0 , -1* ol[quantity] , 0 ))

FarhanAhmed
Community Champion
Community Champion

Para la primera puede cambiar la precisión de la columna en la cinta de opciones "Herramientas de columnas"

DecimalNumberPrecision.png

2o es necesario crear una medida como esta.

_Qty = IF(price > 0,SUM(quantity),SUM(quantity)*-1)







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




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.