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

Counting the number of time a dynamic category appeared

Hello Everyone, 
I hope you are all doing well,
I am stuck at a problem and can't find a ways out. I have a sample table with shops name, target and date. Based on the target a dax measure is written which which will define the category for that particular shop.
for example if I select date between 1 december, 20222 to 2 decemeber 2022 than the category of  a1 store will be "D" however if choose date upto 3 december , 2022 the category of a1 store will be "A".   Following dax is used to assign the category.

-------------------------------------------------------------------------------
Category =
var t1 = sum('Table'[Target])
return
if(t1 >=15 ,"A", if(t1<15 && t1>=10, "B", if(t1>10 && t1<=5, "C","D")))

--------------------------------------------------------------------------------

Screenshot (63).pngScreenshot (64).png
Now I want to count the total number of stores fall in a specefic category based show the total against those stores with respect to the chosen date and show blank in total for category and for count. 

The output should be like this.
Screenshot (65).png


Kindly help

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @spartansquad 
Please refer to attached sample file with the solution

1.png

Count of Category = 
VAR CurrentCategory = [Category]
RETURN
    SUMX ( 
        ALLSELECTED ( 'Table'[Shop] ),
        IF ( 
            [Category] = CurrentCategory,
            1
        )
    )

View solution in original post

2 REPLIES 2
spartansquad
New Member

It worked for me thank you

tamerj1
Super User
Super User

Hi @spartansquad 
Please refer to attached sample file with the solution

1.png

Count of Category = 
VAR CurrentCategory = [Category]
RETURN
    SUMX ( 
        ALLSELECTED ( 'Table'[Shop] ),
        IF ( 
            [Category] = CurrentCategory,
            1
        )
    )

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.