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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
sportive92003
Helper II
Helper II

Why total = 0 ?

Hello,

 

I did this dax new measure to count the new clients, but  the total appears 0. How to count them?

--
Nouveaux clients (1an) =
Var N1=CALCULATE(COUNT('SG LUBRIFIANTS - 2019-2023 data corrigées'[no_client]),
        FILTER(ALL('SG LUBRIFIANTS - 2019-2023 data corrigées'),[no_client]=SELECTEDVALUE('SG LUBRIFIANTS - 2019-2023 data corrigées'[no_client])&&YEAR([date_de_la_facture])=YEAR(TODAY())))
Var N2=CALCULATE(COUNT('SG LUBRIFIANTS - 2019-2023 data corrigées'[no_client]),
        FILTER(ALL('SG LUBRIFIANTS - 2019-2023 data corrigées'),[no_client]=SELECTEDVALUE('SG LUBRIFIANTS - 2019-2023 data corrigées'[no_client])&&YEAR([date_de_la_facture])=YEAR(TODAY())-1))
return
IF(N1>0&&N2=BLANK(),1,0)
----- 

I've tried this but  =0 too:

 

Nouveaux clients (1an) - count = calculate (([Nouveaux clients (1an)]) , all('SG LUBRIFIANTS - 2019-2023 data corrigées'))

 

sportive92003_0-1726510896977.png

 

Thanks!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thanks for the reply from tamerj1 , please allow me to provide another insight:

Hi, @sportive92003 

Regarding the issue you raised, my solution is as follows:
 

In response to your question, I offer two approaches:
 

1.The first is to use the HASONEFILTER () function as the basis for judgment, and then output the SUMX () function as the aggregate.
 

Here are the related links, I hope you will be helpful:

Dealing with Measure Totals - Microsoft Fabric Community
Measure Totals, The Final Word - Microsoft Fabric Community
 

2.The second is to convert the measures into groups of calculations and then modify the aggregation:
 

You can try the following code as a calculated column:

vlinyulumsft_0-1726544524436.png

Then modify the way he aggregates: 

vlinyulumsft_1-1726544524437.png

 

Best Regards,

Leroy Lu

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thanks for the reply from tamerj1 , please allow me to provide another insight:

Hi, @sportive92003 

Regarding the issue you raised, my solution is as follows:
 

In response to your question, I offer two approaches:
 

1.The first is to use the HASONEFILTER () function as the basis for judgment, and then output the SUMX () function as the aggregate.
 

Here are the related links, I hope you will be helpful:

Dealing with Measure Totals - Microsoft Fabric Community
Measure Totals, The Final Word - Microsoft Fabric Community
 

2.The second is to convert the measures into groups of calculations and then modify the aggregation:
 

You can try the following code as a calculated column:

vlinyulumsft_0-1726544524436.png

Then modify the way he aggregates: 

vlinyulumsft_1-1726544524437.png

 

Best Regards,

Leroy Lu

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

tamerj1
Super User
Super User

Hi @sportive92003 

Because SELECTEDVALUE returns BLANK at the total level for the fact that there is no single value available in the filter context of the total. 
is [date_de_la_facture] a measure a column? If measure, what's the DAX? And what's your reason for using ALL? Is it to remove an existing filter in the table visual or a slice?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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