Forum Discussion
Anonymous
3 years agoNot applicable
Help getting a count with 2 filters in the same table
I think its a very simple solution but I can't get the answer
| ID | Description | Date |
| CS | Programmed | 2/2/2023 |
| CS | Purchase | 2/2/2023 |
| CS | Programmed | 3/10/2023 |
| CS | Programmed | 5/9/2023 |
| CS | Purchase | 4/14/2023 |
| CJ | Programmed | 1/30/2023 |
| CJ | Purchase | 1/30/2023 |
| CJ | Programmed | 6/9/2023 |
| CJ | Purchase | 5/19/2023 |
| CI | Purchase | 5/19/2023 |
| CI | Purchase | 6/20/2023 |
| CI | Programmed | 4/28/2023 |
| CI | Programmed | 6/21/2023 |
I want to count the amount of purchase that were made in the same day of the programmed by ID and then divide by another measure
This is what I have for now but I think I'm overcomplicating
% of compliance =
CALCULATE(
COUNTX(
ADDCOLUMNS(
CALCULATETABLE(
SUMMARIZE(Data, Data[ID], Data[Date]),
Data[Description] = "Purchase"
),
"@same",
var _dt = Data[Date]
return
CALCULATETABLE(
VALUES(Data[Date]),
REMOVEFILTERS(Data[Date]),
Data[Description] = "Programmed"),
[@same]
))/[Amount of weeks programmed to today])
Someone told me to do it this way
% of compliance =
VAR _ProgrammedDates =
FILTER(
VALUES(Data[Date]),
Data[Description] = "Programmed"
)
RETURN
DIVIDE(
COUNTX(
FILTER(
ALL(Data),
Data[Description] = "Purchase"
&& Data[Date] IN _ProgrammedDates
),
Data[ID]
),
[Amount of weeks programmed to today]
)
VAR _ProgrammedDates =
FILTER(
VALUES(Data[Date]),
Data[Description] = "Programmed"
)
RETURN
DIVIDE(
COUNTX(
FILTER(
ALL(Data),
Data[Description] = "Purchase"
&& Data[Date] IN _ProgrammedDates
),
Data[ID]
),
[Amount of weeks programmed to today]
)
But it also doesn't work
Please help
Anonymous , please find the attached file
1 Reply
- amitchandak
Super User