Forum Discussion
[HELP] How to create my first DAX
- 9 years ago
In general:
Measure = CALCULATE(COUNT(Table[Column]),FILTER(Table,[DISCOUNT] > 0))
- 9 years ago
Try putting the table name in front of the second column. You'll definitely need to have all of the tables related to one another. Posting some sample/mock data would be very beneficial to posting a solution that would definitely work. You can also look into RELATED and RELATEDTABLE functions. For example, you could do things like:
Measure = CALCULATE(COUNT(Table[Column]),FILTER(Table[DISCOUNT] > 0), FILTER(RELATEDTABLE(Table2), [Item_Sold] > 0))
In general:
Measure = CALCULATE(COUNT(Table[Column]),FILTER(Table,[DISCOUNT] > 0))
- tiago9 years ago
Helper I
Hi SMOUPRE,
You are the best. It worked!!! Only thing that is missing is that I need to count just if Item_Sold > 0 how to add that to your expression?
What happened was that sometimes, there is an item that is returned and this item gets stored on database like this Item_Sold = -1. With the measure that you helped me to create if this product that was returned was on SALE it gets counted like a sold item.
Basically I need to add to that measure an IF to the count so it would coult only if Item_Sold >0.
Thanks you for the help!
- Greg_Deckler9 years ago
Community Champion
Measure = CALCULATE(COUNT(Table[Column]),FILTER(Table,[DISCOUNT] > 0 && [Item_Sold] > 0))
- tiago9 years ago
Helper I
smoupre,
Thank you for the quick response, I will try what you suggested, but DISCOUNT is on the TABLE PRODUCTS_PRICES and Item_Sold is on the TABLE SOLD_ITEMS the way you suggesting DISCOUNT and Item_Sold had to be on the same table no ?
Edit:
As I imagined, it doesnt work, it says that the colum Item_Sold was not found. If you could suggest how to do it would be great.
Thx