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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Syndicate_Admin
Administrator
Administrator

Cómo crear una medida para el rango MAP QTY

Hola, me gustaría modificar mi pregunta que publicó en la semana pasada que todavía no podía averiguar cómo hacerlo suceder después de algunas lecturas.

Estoy tratando de crear una medida para mapear con 2 tablas.

¿Cómo podría SUMAR el "QTY" de la Tabla 1 (250+120+100+30+310+60 a 870)

A continuación, MAP "870" a la Tabla 2 para averiguar la "Banda QTY" como "501 - 1000" para que para buscar en el
1.) Precio unitario como "150"

2.) ID ID como "8"

Aquí está mi prueba, pero realmente no funciona

Measure = MAXX(Filter(SUMX(Table 1, Table 1[QTY]) > Table 2[From], Table 2[QTY Band])

Agradezco si hay ayuda. Este es el ejemplo

https://drive.google.com/file/d/1Pgs73Q9w6vrUjVHrqChixi1inink0uB2/view?usp=sharing

Tabla 1

Producto

Qty

1

100

2

50

3

100

4

30

5

50

6

60

Tabla 2

De

Para

Banda QTY

Precio unitario

Id

1

25

1 - 25

230

1

1

25

1 - 25

250

2

26

100

26 - 100

220

3

101

250

101 - 250

200

4

101

250

101 - 250

210

5

251

500

251 - 500

180

6

251

500

251 - 500

160

7

501

1000

501 - 1000

150

8

1001

5000

1001 - 5000

100

9

Capture.JPG

Lookup QTYBand = 
var _SUM = SUMX('Table 1','Table 1'[QTY])
var _Group = if(AND( _SUM >= 1 , _SUM <=25 ), "1 - 25"
, if(AND( _SUM >= 26 , _SUM <=100 ), "26 - 100"
, if(AND( _SUM >= 101 , _SUM <=250 ), "101 - 250"
, if(AND( _SUM >= 251 , _SUM <=500 ), "251 - 500"
, if(AND( _SUM >= 501 , _SUM <=1000 ), "501 - 1000", "")))))
return
_Group

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

Hola, @ngct1112

Es un placer responder por ti.

No está muy claro qué tipo de visual quieres realmente, creo una medida y utilicé una tarjeta para indicar.

Así:

Measure =
VAR a =
    SUMX ( 'Table 1', [QTY] )
VAR b =
    SUMMARIZE ( 'Table 2', [QTY Band], "Max", MAX ( 'Table 2'[Unit Price] ) )
VAR c =
    ADDCOLUMNS (
        b,
        "fid",
            CALCULATE (
                MAX ( 'Table 2'[ID] ),
                FILTER (
                    'Table 2',
                    [QTY Band] = EARLIER ( 'Table 2'[QTY Band] )
                        && [Unit Price] = EARLIER ( [Max] )
                )
            )
    )
RETURN
    "total is " & a & "," & " max of unit price is"
        & MAXX ( FILTER ( c, [QTY Band] = [Lookup QTYBand] ), [Max] ) & "," & " id is "
        & MAXX ( FILTER ( c, [QTY Band] = [Lookup QTYBand] ), [fid] )

v-janeyg-msft_0-1602670000168.png

Aquí está mi archivo pbix.

https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EVJ4I-18TRhErRaCwGF...

Si no resuelve sus problemas, por favor no dude en preguntarme.

Saludos

Janey Guo

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

View solution in original post

2 REPLIES 2
v-janeyg-msft
Community Support
Community Support

Hola, @ngct1112

Es un placer responder por ti.

No está muy claro qué tipo de visual quieres realmente, creo una medida y utilicé una tarjeta para indicar.

Así:

Measure =
VAR a =
    SUMX ( 'Table 1', [QTY] )
VAR b =
    SUMMARIZE ( 'Table 2', [QTY Band], "Max", MAX ( 'Table 2'[Unit Price] ) )
VAR c =
    ADDCOLUMNS (
        b,
        "fid",
            CALCULATE (
                MAX ( 'Table 2'[ID] ),
                FILTER (
                    'Table 2',
                    [QTY Band] = EARLIER ( 'Table 2'[QTY Band] )
                        && [Unit Price] = EARLIER ( [Max] )
                )
            )
    )
RETURN
    "total is " & a & "," & " max of unit price is"
        & MAXX ( FILTER ( c, [QTY Band] = [Lookup QTYBand] ), [Max] ) & "," & " id is "
        & MAXX ( FILTER ( c, [QTY Band] = [Lookup QTYBand] ), [fid] )

v-janeyg-msft_0-1602670000168.png

Aquí está mi archivo pbix.

https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EVJ4I-18TRhErRaCwGF...

Si no resuelve sus problemas, por favor no dude en preguntarme.

Saludos

Janey Guo

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

lbendlin
Super User
Super User

su última versión se ve razonable, pero se puede simplificar

Lookup QTYBand = 
var _SUM = SUMX('Table 1','Table 1'[QTY])
var _Group = SWITCH(TRUE()
, _SUM>1000,"1001+"
, _SUM>500,"501 - 1000"
, _SUM>250,"251 - 500"
, _SUM>100,"101 - 250"
, _SUM>25,"26 - 100"
, _SUM>0,"1 - 25"
,"")
return
_Group

Helpful resources

Announcements
March Fabric Community Update

Fabric Community Update - March 2024

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

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors