Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hi all,
I am having following problem: I try to dynamically categorise skus to a specific bin type based on their size metrics. The available bin types change dynamically so I created a dropdown list to select the bin types which should be taken into consideration in the measure.
Following measure is used to categorise the SKUs:
What I want however is a count of BinTypeMeasure, to stick to the example above something like this:
S06 | 5 |
B06 | 1 |
Your help is greatly appreciated.
If the powerBI file is needed feel free to contact me
Solved! Go to Solution.
[BinType Count] =
switch( true(),
ISINSCOPE( Bin_Types[Bin Type] ),
var BinType_ = SELECTEDVALUE( Bin_Types[Bin Type] )
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
),
// If we're on a total row or
// if there's no bin type in scope...
SUMX(
ALLSELECTED( Bin_Types ),
var BinType_ = Bin_Types[Bin Type]
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
)
)
)
// Version 2: might be faster...
[BinType Count ver.2] =
var BinTypesWithCounts =
CALCULATETABLE(
ADDCOLUMNS(
VALUES( Bin_Types[Bin Type] ),
"@Count",
var BinType_ = Bin_Types[Bin Type]
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
)
),
ALLSELECTED( Bin_Types )
)
var Result =
IF( ISINSCOPE( Bin_Types[Bin Type] ),
var CurrentBinType =
SELECTEDVALUE( Bin_Types[Bin Type] )
return
MAXX(
FILTER(
BinTypesWithCounts,
Bin_Types[Bin Type] = CurrentBinType
),
[@Count]
),
SUMX(
BinTypesWithCounts,
[@Count]
)
)
return
Result
[BinType Count] =
switch( true(),
ISINSCOPE( Bin_Types[Bin Type] ),
var BinType_ = SELECTEDVALUE( Bin_Types[Bin Type] )
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
),
// If we're on a total row or
// if there's no bin type in scope...
SUMX(
ALLSELECTED( Bin_Types ),
var BinType_ = Bin_Types[Bin Type]
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
)
)
)
// Version 2: might be faster...
[BinType Count ver.2] =
var BinTypesWithCounts =
CALCULATETABLE(
ADDCOLUMNS(
VALUES( Bin_Types[Bin Type] ),
"@Count",
var BinType_ = Bin_Types[Bin Type]
return
COUNTROWS(
FILTER(
DISTINCT( SKU[SKU] ),
[BinTypeMeasure] = BinType_
)
)
),
ALLSELECTED( Bin_Types )
)
var Result =
IF( ISINSCOPE( Bin_Types[Bin Type] ),
var CurrentBinType =
SELECTEDVALUE( Bin_Types[Bin Type] )
return
MAXX(
FILTER(
BinTypesWithCounts,
Bin_Types[Bin Type] = CurrentBinType
),
[@Count]
),
SUMX(
BinTypesWithCounts,
[@Count]
)
)
return
Result
Works like a charm thank you four your help.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
20 | |
13 | |
10 | |
10 | |
8 |
User | Count |
---|---|
20 | |
14 | |
9 | |
7 | |
7 |