Forum Discussion
Filter for newest date by client
- 6 years ago
tvogel8570 OK, I think this makes things more clear. Couple quick questions.
1. Do you have the Row column available in your data?
2. Is the logic the following - summarize (group) the data by Category and Client taking the latest date and then sum the Amt that corresponds to that grouping at those latest date values?
If that logic is correct, then:
Measure = VAR __Category = MAX([Category]) VAR __Table = ADDCOLUMNS( SUMMARIZE( 'Table', [Client], "__Date",MAX([Date]) ), "__Amt",MAXX(FILTER(ALL('Table'),[Category]=__Category && [Client]=EARLIER([Client]) && [Date]=EARLIER([__Date])),[Amt]) ) RETURN SUMX(__Table,[__Amt])
Greg and Ashish,
Both of you gave me what I asked for but it doesn't really work for what I need. 😉
I come from a strong SQL background and I'm trying to fit my SQL approach to DAX which is probably causing me problems.
So I am revsing my original question...
Summarize invoice details such that the result has the newest invoice for each customer by category(s).
The challenge I have been having is that the newest invoice date differs by customer. All of the pivot tables that do not explicitly have client in them miss clients' with invoice date that is older than the newest across the entire table, i.e. row #8 in image.
Source data in blue, desired result in Green, incorrect in orange / red.
- Greg_Deckler6 years ago
Community Champion
tvogel8570 OK, I think this makes things more clear. Couple quick questions.
1. Do you have the Row column available in your data?
2. Is the logic the following - summarize (group) the data by Category and Client taking the latest date and then sum the Amt that corresponds to that grouping at those latest date values?
If that logic is correct, then:
Measure = VAR __Category = MAX([Category]) VAR __Table = ADDCOLUMNS( SUMMARIZE( 'Table', [Client], "__Date",MAX([Date]) ), "__Amt",MAXX(FILTER(ALL('Table'),[Category]=__Category && [Client]=EARLIER([Client]) && [Date]=EARLIER([__Date])),[Amt]) ) RETURN SUMX(__Table,[__Amt])- tvogel85706 years agoRegular Visitor
Greg,
1. The Row column I added to help with the explanation.
2. Correct. There will be other categories in the future that may be on a related table but I "assume" that I can get at them through the RELATED operator. Also will likely need to UNION the invoice table with another table that has the same schema but expected sales rather than actual sales.
Timothy