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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Count of measure

Hi Guys,

 

Some help on this issue would be greatly appreciated!

 

The below Matrix indicates if a Store have inventory of a Product during three consecutive Months. Then, last two columns indicate if a Product have dropped/gain inventory from one Month to another.

PBI issue pic 2.PNG

 

 

I would like two measures:

  • One measure that calculates the Count of  
  • One measure that calculates the Count of ↓

Is this possible?

 

Here is how I calculated my other measures:

Month 1 vs Month 2 = IF ( [Month 1] <> BLANK() && [Month 2] = [Month 1] , "↔" , IF( [Month 3] = "Yes" && [Month 2] = "No" , "↓" , IF( [Month 1] = "No" && [Month 2] = "Yes" , "↑")))

Month 2 = CALCULATE( FIRSTNONBLANK( 'Products Table'[Answer],0), 'Products Table'[MonthNumber] = MONTH(TODAY())-1)

 

Month 1 = CALCULATE( FIRSTNONBLANK( 'Products Table'[Answer],0), 'Products Table'[MonthNumber] = MONTH(TODAY())-2)

 

Here is an extract of the data:

Store nameProductMonthNumberMonthAnswer
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Fill and Go Replacement Filter and Cap 1pk7JulyYes
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Fill and Go Replacement Filter and Cap 1pk6JuneYes
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Fill and Go Replacement Filter and Cap 1pk5MayYes
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Filter Cartridge 1pk6JuneNo
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Filter Cartridge 1pk7JulyYes
FOODLAND IGA HOPE VALLEY DRAKESBrita Classic Filter Cartridge 1pk5MayYes
FOODLAND IGA HOPE VALLEY DRAKESBrita Fill and Go Active Blue Water Bottle 600ml7JulyNo
FOODLAND IGA HOPE VALLEY DRAKESBrita Fill and Go Active Blue Water Bottle 600ml6JuneNo
FOODLAND IGA HOPE VALLEY DRAKESBrita Fill and Go Active Blue Water Bottle 600ml5MayNo

 

Please note: My data contains many stores.

 

Thanks in advance.

Robin

1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi Robin,

 

You may try  SUMMARIZE Function  like below.

Total Count of ↑ =
VAR Mon1vMon2In =
    CALCULATE (
        SUMX (
            SUMMARIZE (
                'Products Table',
                'Products Table'[Product],
                "a", [Month 1 vs Month 2]
            ),
            IF ( [a] = "↑", 1, 0 )
        )
    )
RETURN
    VAR Mon2vMon3In =
        CALCULATE (
            SUMX (
                SUMMARIZE (
                    'Products Table',
                    'Products Table'[Product],
                    "a", [Month 2 vs Month 3]
                ),
                IF ( [a] = "↑", 1, 0 )
            )
        )
    RETURN
        Mon1vMon2In + Mon2vMon3In
Total Count of ↓ =
VAR Mon1vMon2De =
    CALCULATE (
        SUMX (
            SUMMARIZE (
                'Products Table',
                'Products Table'[Product],
                "a", [Month 1 vs Month 2]
            ),
            IF ( [a] = "↓", 1, 0 )
        )
    )
RETURN
    VAR Mon2vMon3De =
        CALCULATE (
            SUMX (
                SUMMARIZE (
                    'Products Table',
                    'Products Table'[Product],
                    "a", [Month 2 vs Month 3]
                ),
                IF ( [a] = "↓", 1, 0 )
            )
        )
    RETURN
        Mon1vMon2De + Mon2vMon3De

countofmeasure

 

Best Regards,

Dale

Community Support Team _ Dale
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

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi Robin,

 

You may try  SUMMARIZE Function  like below.

Total Count of ↑ =
VAR Mon1vMon2In =
    CALCULATE (
        SUMX (
            SUMMARIZE (
                'Products Table',
                'Products Table'[Product],
                "a", [Month 1 vs Month 2]
            ),
            IF ( [a] = "↑", 1, 0 )
        )
    )
RETURN
    VAR Mon2vMon3In =
        CALCULATE (
            SUMX (
                SUMMARIZE (
                    'Products Table',
                    'Products Table'[Product],
                    "a", [Month 2 vs Month 3]
                ),
                IF ( [a] = "↑", 1, 0 )
            )
        )
    RETURN
        Mon1vMon2In + Mon2vMon3In
Total Count of ↓ =
VAR Mon1vMon2De =
    CALCULATE (
        SUMX (
            SUMMARIZE (
                'Products Table',
                'Products Table'[Product],
                "a", [Month 1 vs Month 2]
            ),
            IF ( [a] = "↓", 1, 0 )
        )
    )
RETURN
    VAR Mon2vMon3De =
        CALCULATE (
            SUMX (
                SUMMARIZE (
                    'Products Table',
                    'Products Table'[Product],
                    "a", [Month 2 vs Month 3]
                ),
                IF ( [a] = "↓", 1, 0 )
            )
        )
    RETURN
        Mon1vMon2De + Mon2vMon3De

countofmeasure

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Dale,

 

Thanks a lot for your time, I really appreciate.

 

Your formula works perfectly for the mentioned visualisation.

 

However, ideally I would like to use it in the below visualisation (just with product column), and it's not giving me a correct count...

Power bi Screenshot.PNG

 

Would you know how to fix this please?

 

Robin

Hi Robin,

 

Please add other measures into the table to check if these 0s are the answer.  If so, I'm afraid there could be something wrong with other parts. Can you share the pbix file and expected output please? You can upload it to OneDrive or Dropbox and post the link here. Do mask sensitive data before uploading.

Count_of_measure

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

All good I got it! I was playing around with the SUMMARIZE function you sent and I manage to get the correct answer:

I replaced 

'Products Table'[Product] 

by

'Products Table'[Store]

 

Many thanks again

Robin

Hi,

 

So if you select a certain month in the slicer, say July, do you want to know which products increased over the previous month and which decreased over the previous month?  If my understanding is correct, then the answer will be 1 or 0.  Am i correct?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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