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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
sboinala
Regular Visitor

Valores de recuento

Tengo dos mesas

Clientes
a
b
c
d
e
f

Tipo de cuenta:

ClienteCombustible
aGas
aElec
bGas
cGas
cElec
dGas
dElec
eElec
eElec
fGas
fGas

Salida requerida

ClienteRecuentos de gas y elecRecuento de solo gasElec Only Count
a1
b01
c1
d1
e0 1
f 1

La matriz de la visílacuo sería:

Recuentos de gas y elec3
Recuentos de gases2
Elec Counts1
1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hola

Por favor, pruebe estas tres medidas primero:

Gas & Elec Counts = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) > 1,
            1,
            0
        )
    )
)
Gas Only Count = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) = 1
                && CALCULATE (
                    MAX ( 'Account Type'[Fuel] ),
                    FILTER (
                        ALLSELECTED ( 'Account Type' ),
                        'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                    )
                ) = "Gas",
            1,
            0
        )
    )
)
Elec Only Count = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) = 1
                && CALCULATE (
                    MAX ( 'Account Type'[Fuel] ),
                    FILTER (
                        ALLSELECTED ( 'Account Type' ),
                        'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                    )
                ) = "Elec",
            1,
            0
        )
    )
)

A continuación, cree una tabla de segmentación de datos mediante Introducir datos:

85.PNG

A continuación, pruebe esta medida de recuento:

Count =
SUMX (
    DISTINCT ( 'Slicer Table'[Category] ),
    CALCULATE (
        SWITCH (
            MAX ( 'Slicer Table'[Category] ),
            "Elec Counts", [Elec Only Count],
            "Gas  Counts", [Gas Only Count],
            "Gas & Elec Counts", [Gas & Elec Counts]
        )
    )
)

El resultado muestra:

90.PNG

91.PNG

Aquí está mi archivo pbix de prueba:

pbix

Espero que esto ayude.

Saludos

Giotto Zhi

View solution in original post

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hola

Por favor, pruebe estas tres medidas primero:

Gas & Elec Counts = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) > 1,
            1,
            0
        )
    )
)
Gas Only Count = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) = 1
                && CALCULATE (
                    MAX ( 'Account Type'[Fuel] ),
                    FILTER (
                        ALLSELECTED ( 'Account Type' ),
                        'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                    )
                ) = "Gas",
            1,
            0
        )
    )
)
Elec Only Count = 
SUMX (
    DISTINCT ( Customer[Customers] ),
    CALCULATE (
        IF (
            CALCULATE (
                DISTINCTCOUNT ( 'Account Type'[Customer&Fuel] ),
                FILTER (
                    ALLSELECTED ( 'Account Type' ),
                    'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                )
            ) = 1
                && CALCULATE (
                    MAX ( 'Account Type'[Fuel] ),
                    FILTER (
                        ALLSELECTED ( 'Account Type' ),
                        'Account Type'[Customer] IN FILTERS ( Customer[Customers] )
                    )
                ) = "Elec",
            1,
            0
        )
    )
)

A continuación, cree una tabla de segmentación de datos mediante Introducir datos:

85.PNG

A continuación, pruebe esta medida de recuento:

Count =
SUMX (
    DISTINCT ( 'Slicer Table'[Category] ),
    CALCULATE (
        SWITCH (
            MAX ( 'Slicer Table'[Category] ),
            "Elec Counts", [Elec Only Count],
            "Gas  Counts", [Gas Only Count],
            "Gas & Elec Counts", [Gas & Elec Counts]
        )
    )
)

El resultado muestra:

90.PNG

91.PNG

Aquí está mi archivo pbix de prueba:

pbix

Espero que esto ayude.

Saludos

Giotto Zhi

az38
Community Champion
Community Champion

Hola @sboinala

¿Veo 2 salidas requeridas en tu publicación? ¿qué necesitas exactamente?

para la primera matriz simplemente creauna una matriz visual, suelte el campo Cliente a filas, Combustible en columnas, Cliente a valores y establezca el parámetro de agregación Valores como Recuento (Distinct)

para segundo, combustible - como filas, cliente como valores y el mismo parámetro de agregación Valores establecido como Recuento (Distinct)


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

La salida que estoy buscando es:

Gas & Elec3
Gas2
Elec1

No conseguimos encontrar tu ubicación exacta.

az38
Community Champion
Community Champion

@sboinala

crear una columna

FuelType = 
var _isGas = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Customer]),'Table'[Fuel]="Gas")
var _isElec = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Customer]),'Table'[Fuel]="Elec")
RETURN
SWITCH(TRUE(),
_isElec > 0 && _isGas > 0, "Gas & Elec",
_isElec > 0, "Elec Only",
_isGas > 0, "Gas Only"
)

a continuación, agregue la nueva columna FuelType como filas y Count(Distinct) de Customers como Value


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors