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
mbylicki
Frequent Visitor

Comparar datos basados en 2 valores seleccionados en 1 columna

Hola

actualmente estamos cambiando de Qlik a Power BI, y nos enfrentamos a este problema.

Cargamos varios archivos en una tabla (ejemplo simple a continuación)

mbylicki_0-1605714844434.png

Lo que queremos lograr es permitir que el usuario elija 2 nombres de archivo diferentes y comparar (por ejemplo, restar) todas las medidas (Vender en el ejemplo).

En QlikView teníamos 2 listas de 'Nombre de archivo' y usamos estados alternativos.

En Power BI intenté crear 2 campos con 'Nombre de archivo' cada uno, crear una medida para obtener el valor seleccionado de cada uno y, finalmente, usar la fórmula CALCULATE, pero no puedo poner una medida creada.

CALCULATE(sum('INPUT TABLE'[Sell]),'INPUT TABLE'[Nombre de archivo]-"Archivo B")-CALCULATE(sum('INPUT TABLE'[Sell]),'INPUT TABLE'[Nombre de archivo]-"Archivo A")

En otras palabras, cómo hacer valores rojos por encima de la elección dinámica por usuario.

Aquí está la solución basada en Excel

Apreciaré cualquier ayuda

¡Gracias!

Maciej

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @mbylicki ,

 

The Dax function of Selectvalue is suitable for single sign-on. It is suitable for when only one is selected, there will be a value, otherwise there will be no value

 

For example: I need to select a month and display the value of the previous month, this can use selectvalue

v-yangliu-msft_0-1605857123160.png

Dax formula:

Measure =
var _1=SELECTEDVALUE('Table'[month])
var _2=CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[month]=_1-1))
return _2

Put month into slice and measure into card. By selecting May, the amount in April is displayed

v-yangliu-msft_1-1605857123163.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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

v-yangliu-msft
Community Support
Community Support

Hola @mbylicki ,

Estos son los pasos que puede seguir:

1. Crear medida.

compara =
var _max = MAX('Table'[File name])
var _min = MIN('Table'[File name])

return CALCULATE(SUM('Table'[Sell]),ALLEXCEPT('Table','Table'[Client]),FILTER('Table','Table'[File name]=_max)) - CALCULATE(SUM('Table'[Sell]),ALLEXCEPT('Table','Table'[Client]),FILTER('Table','Table'[File name]=_min))

2. Resultado.

v-yangliu-msft_0-1605773391740.png

Puede descargar el archivo PBIX desde aquí.

Saludos

Liu Yang

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

Gracias v-yangliu-msft

He modificado Su solución usando 2 segmentaciones independientes, así que también medir En cambió de "MAX/MIN" a "SELECTEDVALUE" pero Su fórmula detuvo el trabajo 😞 ¿Podría por favor comprobar lo que estoy haciendo mal.

Comparto PBIX modificado aquí

¡Gracias!

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.