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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gbarr12345
Post Prodigy
Post Prodigy

MacBook Sold in April measure

Hi everyone,

 

I'm looking to create a measure to put onto a card visualisation based on the number of Mac Books Sold in April.

 

I created the measure and got no error but when I pull it into a card the number that appears is incorrect.

 

Any idea why this number is a lot higher than it should be?

 

I have the code below and PBIX attached.

 

MacBook Sold April =
VAR _Item = SELECTEDVALUE( 'Sales Table'[Item Code])
VAR _Period = SELECTEDVALUE( 'Sales Table'[Period])
VAR Sales_Period =
    VALUES( 'Sales Table'[Period] )
VAR VirtualTable =
    FILTER(
        SUMMARIZE(
            'Sales Table' ,
            'Sales Table'[Period] ,
            'Sales Table'[Item Code] ,
            'Dimension_Item Table'[Item Description]
        ),

        'Sales Table'[Item Code] = 7
        || 'Sales Table'[Period] = 202404
    )
    RETURN
    COUNTROWS(VirtualTable)

 

PBIX - https://drive.google.com/file/d/1pRRLgjcz7Ooo-yXndknfLtYqryr0lOR3/view?usp=drive_link

 

gbarr12345_0-1716238679324.png

 

gbarr12345_1-1716238688260.png

 

1 ACCEPTED SOLUTION
nandic
Super User
Super User

@gbarr12345 you could try this formula:

CALCULATE(COUNTROWS(FILTER('Sales Table','Sales Table'[Item Code]=7 && 'Sales Table'[Period]=202404)))

It returns 3 as there are 3 transactions.
In your formula there are 2 issues: it is checking for all rows that are either MacBook Pro OR period 202204. We need AND condition instead of OR.
Another issue is that you grouped based on period/item in virutal table, so it will group by Macbook Pro 202204, returning only 1 row count.
If you used summarize, you would need to add another group by transaction to get count of transactions.

Cheers,
Nemanja Andic

View solution in original post

2 REPLIES 2
nandic
Super User
Super User

@gbarr12345 you could try this formula:

CALCULATE(COUNTROWS(FILTER('Sales Table','Sales Table'[Item Code]=7 && 'Sales Table'[Period]=202404)))

It returns 3 as there are 3 transactions.
In your formula there are 2 issues: it is checking for all rows that are either MacBook Pro OR period 202204. We need AND condition instead of OR.
Another issue is that you grouped based on period/item in virutal table, so it will group by Macbook Pro 202204, returning only 1 row count.
If you used summarize, you would need to add another group by transaction to get count of transactions.

Cheers,
Nemanja Andic

That worked! Thank you so much Nemanja.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.