Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
SK01
Frequent Visitor

TopN while using duplicate values

Hi everyone,

 

I need your help with the following problem. I need to be able to display the topN cargo ID based on their cycle time. 

I am trying to use TOPN to display values based on the lowest cycle time. So for example, when you input a value into a slider slicer, that same value should correspond to the amount of units shown. 

 

The desired result would be something similar to this. 'Units' is calculated by using the COUNT formula on the cargo id column.

SK01_0-1686551654881.png

 

The concat column might not be necessary fyi, but I included it just in case.

Below you can find the dummy data:

Cargo IDCycle TimeLocationConcat
VIN1500CKX500VIN1
VIN2500CKX500VIN2
VIN3500CKX500VIN3
VIN4500CKX500VIN4
VIN5500CKX500VIN5
VIN6500CKX500VIN6
VIN7500CKX500VIN7
VIN8500CKX500VIN8
VIN9500CKX500VIN9
VIN10500CKX500VIN10
VIN11500CKX500VIN11
VIN12500CKX500VIN12
VIN13500CKX500VIN13
VIN14500CKX500VIN14
VIN15500CKX500VIN15
VIN16500CKX500VIN16
VIN17500CKX500VIN17
VIN18500CKX500VIN18
VIN19500CKX500VIN19
VIN20500CKX500VIN20
VIN21500CKX500VIN21
VIN22500CKX500VIN22
VIN23500CKX500VIN23
VIN24500CKX500VIN24
VIN25500CKX500VIN25
VIN26500CKX500VIN26
VIN27550P9550VIN27
VIN28550P9550VIN28
VIN29550P9550VIN29
VIN30550P9550VIN30
VIN31550P9550VIN31
VIN32550P9550VIN32
VIN33550P9550VIN33
VIN34550P9550VIN34
VIN35550P9550VIN35
VIN36550P9550VIN36
VIN37550P9550VIN37
VIN38550P9550VIN38
VIN39550P9550VIN39
VIN40550P9550VIN40
VIN41550P9550VIN41
VIN42550P9550VIN42
VIN43550P9550VIN43
VIN44550P9550VIN44
VIN45550P9550VIN45
VIN46550P9550VIN46
VIN47550P9550VIN47
VIN48550P9550VIN48
VIN49550P9550VIN49
VIN50550P9550VIN50
VIN51550P9550VIN51
VIN52550P9550VIN52
VIN53550P9550VIN53
VIN54550P9550VIN54
VIN55550P9550VIN55
VIN56600CKU600VIN56
VIN57600CKU600VIN57
VIN58600CKU600VIN58
VIN59600CKU600VIN59
VIN60600CKU600VIN60
VIN61600CKU600VIN61
VIN62600CKU600VIN62
VIN63600CKU600VIN63
VIN64600CKU600VIN64
VIN65600CKU600VIN65
VIN66600CKU600VIN66
VIN67600CKU600VIN67
VIN68600CKU600VIN68
VIN69600CKU600VIN69
VIN70600CKU600VIN70
VIN71600CKU600VIN71
VIN72600CKU600VIN72
VIN73600CKU600VIN73
VIN74600CKU600VIN74
VIN75600CKU600VIN75
VIN76600CKU600VIN76
VIN77600CKU600VIN77
VIN78600CKU600VIN78
VIN79600CKU600VIN79
VIN80600CKU600VIN80
VIN81600CKU600VIN81
VIN82600CKU600VIN82
VIN83650P26650VIN83
VIN84650P26650VIN84
VIN85650P26650VIN85
VIN86650P26650VIN86
VIN87650P26650VIN87
VIN88650P26650VIN88
VIN89650P26650VIN89
VIN90650P26650VIN90
VIN91650P26650VIN91
VIN92650P26650VIN92
VIN93650P26650VIN93
VIN94650P26650VIN94
VIN95650P26650VIN95
VIN96650P26650VIN96
VIN97650P26650VIN97
VIN98650P26650VIN98
VIN99650P26650VIN99
VIN100650P26650VIN100

 

 

 

1 ACCEPTED SOLUTION
SK01
Frequent Visitor

@v-xinruzhu-msft I have found a solution.
 
For anyone interested, here is the measure that uses a slicer to appoint the Top N.
 
Measure =
 
VAR a =
    CALCULATETABLE(
        VALUES(
            'Table'[Cargo ID]),
                TOPN(
                    SELECTEDVALUE(
                        Slicer[Slicer]),
                    ALLSELECTED(
                        'Table'),
                        'Table'[RND Time],
                ASC)
    )

VAR selectedCargoID = SELECTEDVALUE ( 'Table'[Cargo ID] )
RETURN
    IF ( selectedCargoID IN b, 1, 0 )

View solution in original post

4 REPLIES 4
SK01
Frequent Visitor

@v-xinruzhu-msft I have found a solution.
 
For anyone interested, here is the measure that uses a slicer to appoint the Top N.
 
Measure =
 
VAR a =
    CALCULATETABLE(
        VALUES(
            'Table'[Cargo ID]),
                TOPN(
                    SELECTEDVALUE(
                        Slicer[Slicer]),
                    ALLSELECTED(
                        'Table'),
                        'Table'[RND Time],
                ASC)
    )

VAR selectedCargoID = SELECTEDVALUE ( 'Table'[Cargo ID] )
RETURN
    IF ( selectedCargoID IN b, 1, 0 )
SK01
Frequent Visitor

Hey thank you for replying.

This is not exactly the solution I am looking for. Top N should correlate to the amount of units returned; right now it returns 4 values at a maximum.

The desired result would be if Top N is set to 15 to return 15 units based on their lowest times.

I am currently trying something out using AVERAGE('Table'[Cycle Time])+RAND()/100, to create unique time values so that it can be properly displayed. However it doesn't interact well with your measure.

Example:

All possible units.

SK01_0-1686729121799.png

Filter:

SK01_6-1686729307855.png

Result:

SK01_5-1686729297525.png

Note that I am using a different dataset to illustrate.

Can you help me out further?

 

 

SK01
Frequent Visitor

Just to clarify, the example is only to showcase how I'd like the measure to interact with the data in question, nothing more.

v-xinruzhu-msft
Community Support
Community Support

Hi @SK01 

You can create a measure

Measure 2 = var a=SUMMARIZE(ALLSELECTED('Table'),'Table'[Location],"MinID",MIN('Table'[Cargo ID]),"Mincycletime",MIN('Table'[Cycle Time]))
var b=TOPN(3,a,[Mincycletime],ASC)
var c=SELECTCOLUMNS(b,"minid",[MinID])
return IF(SELECTEDVALUE('Table'[Cargo ID]) in c,1,0)

Then put the measure to the visual filter

vxinruzhumsft_0-1686708075095.png

 

Output

vxinruzhumsft_1-1686708083463.png

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.