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
Higoricardo
New Member

Count rows of a summarize table with blank values

I have a client base with two measures: Sellout Value and Sellout Value Last Year, like below:

 

Imagem1.png

Sellout Value = SUM(SELLOUT_TABLE[SELLOUT_VALUE])

Sellout Value Last Year = CALCULATE([Sellout Value],PREVIOUSYEAR(CALENDAR[Date]))

 

An IF measure was created to categorize clients to be rescued, following the logic of those who bought last year but didn’t buy this year.

 

Client to Rescue = IF([Sellout Value]<=0&&[Sellout Value Last Year]>0,"YES","NO")

 

The challenge here is to create a measure that counts and consolidate the number of clients which is categorized as a client to be rescued. The measure below was created but the return is resulting as blank.

 

Imagem2.png

 

Clients to Rescue = COUNTROWS(FILTER(ADDCOLUMNS(SUMMARIZE(SELLOUT_TABLE, SELLOUT_TABLE [CLIENT_CODE]), "Sellout Value", [Sellout Value], " Sellout Value Last Year", [Sellout Value Last Year]),[Client to Rescue]="YES"))

 

Is there any fix in the DAX formulas used or in the base to result the count correctly?

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

Hi  @Higoricardo ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _table1=
SUMMARIZE(ALLSELECTED('Table'),[Client Code],"Measure",[Client to Rescue])
var _table2=
FILTER(
    _table1,[Measure]="YES")
return
IF(
MAX('Table'[Client Code]) in SELECTCOLUMNS(_table2,"test",[Client Code]),1,BLANK())
Clients to Rescue =
CALCULATE(DISTINCTCOUNT('Table'[Client Code]),ALLSELECTED('Table'))

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1712817260733.png

3. Result:

vyangliumsft_1-1712817260736.png

 

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

View solution in original post

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

Hi  @Higoricardo ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _table1=
SUMMARIZE(ALLSELECTED('Table'),[Client Code],"Measure",[Client to Rescue])
var _table2=
FILTER(
    _table1,[Measure]="YES")
return
IF(
MAX('Table'[Client Code]) in SELECTCOLUMNS(_table2,"test",[Client Code]),1,BLANK())
Clients to Rescue =
CALCULATE(DISTINCTCOUNT('Table'[Client Code]),ALLSELECTED('Table'))

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1712817260733.png

3. Result:

vyangliumsft_1-1712817260736.png

 

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

kriscoupe
Solution Supplier
Solution Supplier

Hi @Higoricardo ,

 

So, I'm assuming you want to get the number of clients that would have been YES client to rescue. You should be able to achieve this using the following formula.

 

Number of Clients to Rescue =
COUNTROWS(
    FILTER(
        VALUES( SELLOUT_TABLE[CLIENT_CODE] ),
        [Client to Rescue] = "YES"
    )
)

 

Not to sure on your model structure etc. but based on what I see above this should work. Let me know how you get on.

 

Hope it helps,

Kris

Hi @kriscoupe !

 

Thank you for answering, but it didn't work. It's returning just 1 client and as we can see in the base, there are more than one client categorized as to be rescued. 

 

Ind. Distribuidor 2 1.jpg

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!

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.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.