Forum Discussion
distinctcount item filtered by value
- Anonymous1 year ago
Thank you bhanu_gautam, I have the following thoughts:
Hi, Mike91
Based on your chat with Super User, I used the example data you provided as shown in the image below:
First, I create a calculated table using this DAX expression:
Table 2 = VAR _table = SUMMARIZE( 'Table', 'Table'[Date], 'Table'[Item], 'Table'[Value], "Month", FORMAT( 'Table'[Date], "MMMM" ), "Year", FORMAT( 'Table'[Date], "YYYY" ) ) RETURN ADDCOLUMNS( ADDCOLUMNS( SUMMARIZE( _table, 'Table'[Item], [Month], [Year] ), "Res", VAR _year = [Year] VAR _month = [Month] VAR _item = 'Table'[Item] RETURN SUMX( FILTER( ALL('Table'), FORMAT( 'Table'[Date], "YYYY" ) = _year && FORMAT( 'Table'[Date], "MMMM" ) = _month && 'Table'[Item] = _item ), 'Table'[Value] ) ), "IsAbove100", IF( [Res] > 100, 1, 0 ) )This will calculate the total values for each item for each month and determine if the total values for that month are greater than 100.
I then created two measures using the following two expressions:
Above100 = COUNTAX(FILTER(SUMMARIZE('Table 2','Table 2'[IsAbove100],'Table 2'[Item]),'Table 2'[IsAbove100]=1),'Table 2'[Item])Below100 = COUNTAX(FILTER(SUMMARIZE('Table 2','Table 2'[IsAbove100],'Table 2'[Item]),'Table 2'[IsAbove100]=0),'Table 2'[Item])At this point, we use the columns and months of the calculated table to create a table visual, a slicer, and a card, respectively:
When I select any month in the slicer, it calculates whether the total value of the corresponding item is greater than 100 items.
I've provided the Pbix file below.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mike91 , Create a measure to calculate the total sales for each item:
ItemsUnder100 =
CALCULATE(
COUNTROWS('Table'),
FILTER(
'Table',
[TotalSales] < 100
)
)
- Mike911 year ago
Helper I
i tried, but not working count a number of transaction for each item. for example in my dataset in april i sold 328 item, i calculate in excell 100 of them sold <100, with you formula i count the single transaction under 100 for each item.
- bhanu_gautam1 year ago
Super User
Mike91 , It is not clear can you explain in detail with example what exactly are you looking for
- Mike911 year ago
Helper I
i hope this screen can be more clear, in excell i use the pivot to calculate the total value for each item, and use a count.if to count the number of item with different condition.
with your dax i count the different transaction during the month under <100, i need count the total sales for each product during the month and count the item soddisfy my condition.