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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Customers with invoices or delivery notes or orders

Hola,
Quiero contar cuantos clientes distintos hay en la tabla de facturas, albaranes o pedidos. De tal manera que independiente del numero de veces que aparece, me cuente un cliente. Se me ha ocurrido esto pero ¿Hay alguna manera más efectiva de hacerlo?



#Clientes con ventas =
VAR _EsteMes = MAX( [MonthKey] )
VAR _TablaDaily =

UNION(
Filter(
Values( [Id_sk_Clientes] ),
MAx([Monthkey])=_EsteMes),
Filter(
Values( [Id_sk_ClientesAlbaranes] ),
Max([Monthkey])=_EsteMes),
Filter(
Values( [Id_sk_ClientesPedidos] ),
MAx([MonthKey])=_EsteMes)
)

Return
COUNTROWS(SUMMARIZE(_TablaDaily, [Id_sk_Clientes] ))
4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

He puesto esto pero me dice "Table variable '_TablaDily' cannot be used in current context because a base table is expected".

#Clientes with sales =

WERE _EsteMes = MAX('Date'[MonthKey])

WERE _TablaDaily =



UNION(

Filter(

Values('Sales Invoices'[Id_sk_Clientes]),

MAx('Date'[Monthkey])=_EsteMes),

Filter(

Values('Sales Delivery Notes'[Id_sk_Clientes]),

Max('Date'[Monthkey])=_EsteMes),

Filter(

Values('Sell Orders'[Id_sk_Clientes]),

MAx('Date'[MonthKey])=_EsteMes)

)



Return

DistinctCount(_TablaDaily[Id_sk_Clientes])

Hi, @Syndicate_Admin 

The reason for the error message is that the DAX measure can only return a single value, not the entire table. You are trying to return the entire table, which is not allowed. The above DAX using Distinctcount is my idea, can you provide some sample data or PBIX files, and please do not divulge your privacy information.

 

Best Regards

Yongkang Hua

 

v-yohua-msft
Community Support
Community Support

Hi, @Syndicate_Admin 


Maybe you can try the DISTINCTCOUNT function instead of COUNTROWS and SUMMARIZE, like this:

 

#Clientes con ventas = 
VAR _EsteMes = MAX( [MonthKey] )
VAR _TablaDaily =
UNION(
    Filter(
        Values( [Id_sk_Clientes] ),
        MAx([Monthkey])=_EsteMes),
    Filter(
        Values( [Id_sk_ClientesAlbaranes] ),
        Max([Monthkey])=_EsteMes),
    Filter(
        Values( [Id_sk_ClientesPedidos] ),
        MAx([MonthKey])=_EsteMes)
)
Return
DISTINCTCOUNT(_TablaDaily[Id_sk_Clientes])

 

 

How to Get Your Question Answered Quickly 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data)

Best Regards

Yongkang Hua

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

lbendlin
Super User
Super User

You would use EXCEPT to find the difference.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.