Hello All,
I've been struggling with an issue and was wondering if anyone might lend some guidance.
3 tables exist in my data model...
I. Store, ProductCategory
II. Store
III. Store, UnitSales, DollarSales
A many to many relationship exists between tables i & iii via ii.
I am trying to return the # of stores that share a Product Category and have Sales above a certain amount.
So far, I've used a calculated column in TableI to get the number of stores which share the product category...
PC1:=CALCULATE(
COUNTROWS(TableI),
MID(TableI[ProductCategory],17,4)="C123",
FILTER(TableI,
TableI[ProductCategory]=EARLIER(TableI[ProductCategory],1)
)
)
Then, because each Store could have up to 2 "C123" Product Categories, I made a couple Calculated Fields...
PC1A:=MIN(TableI[PC1])
PC1B:=IF(
SUM(TableI[PC1])-MIN(TableI[PC1])=0,
blank(),
SUM(TableI[PC1])-MIN(TableI[PC1])
)
Now, I am trying to countrows of TableII by filtering based on the formulae shown above AND new formula(e) from TableIII (yet to be made).
I've tried the formula below to no avail...
SortTableII:=CALCULATE(COUNTROWS(TableII),
FILTER(TableII,
CALCULATE(COUNTROWS(TableI),
FILTER(TableI,
MID(TableI[ProductCategory],17,4)="C123"),
FILTER(TableI,TableI[ProductCategory]=EARLIEST(TableI[ProductCategory])))>0),
FILTER(TableII,
CALCULATE(COUNTROWS(TableIII),
FILTER(TableIII,
[UnitSales]>0||(2*ABS([UnitSales]))<[DollarSales]))>0)
)
Any thoughts?
Thanks kindly,
Paul G.
I've been struggling with an issue and was wondering if anyone might lend some guidance.
3 tables exist in my data model...
I. Store, ProductCategory
II. Store
III. Store, UnitSales, DollarSales
A many to many relationship exists between tables i & iii via ii.
I am trying to return the # of stores that share a Product Category and have Sales above a certain amount.
So far, I've used a calculated column in TableI to get the number of stores which share the product category...
PC1:=CALCULATE(
COUNTROWS(TableI),
MID(TableI[ProductCategory],17,4)="C123",
FILTER(TableI,
TableI[ProductCategory]=EARLIER(TableI[ProductCategory],1)
)
)
Then, because each Store could have up to 2 "C123" Product Categories, I made a couple Calculated Fields...
PC1A:=MIN(TableI[PC1])
PC1B:=IF(
SUM(TableI[PC1])-MIN(TableI[PC1])=0,
blank(),
SUM(TableI[PC1])-MIN(TableI[PC1])
)
Now, I am trying to countrows of TableII by filtering based on the formulae shown above AND new formula(e) from TableIII (yet to be made).
I've tried the formula below to no avail...
SortTableII:=CALCULATE(COUNTROWS(TableII),
FILTER(TableII,
CALCULATE(COUNTROWS(TableI),
FILTER(TableI,
MID(TableI[ProductCategory],17,4)="C123"),
FILTER(TableI,TableI[ProductCategory]=EARLIEST(TableI[ProductCategory])))>0),
FILTER(TableII,
CALCULATE(COUNTROWS(TableIII),
FILTER(TableIII,
[UnitSales]>0||(2*ABS([UnitSales]))<[DollarSales]))>0)
)
Any thoughts?
Thanks kindly,
Paul G.