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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Adding a filter to a table (in DAX)

I have this table below which computes Mode.  

 

I have a calculated column that is essentially a true/false column.   I want to compute the mode for each of those choices (the true ones, and the false ones), but based on the measure below.  Just adding that column as a slicer or filter on this measure does not work.  

 

Any ideas?

 

Mode_ShippedQty =
TOPN (
1,
ADDCOLUMNS (
VALUES ( ShippedOrders2022_Query[ShippedQty] ),
"Frequency", CALCULATE (COUNT ( ShippedOrders2022_Query[ShippedQty] ) )
),
[Frequency], 0
)
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Your measure mainly used a TOPN function, which will return a row in your formula instead of a value.

I create a sample. Single or Bulk is a calculated column according to your description.

vkalyjmsft_0-1656481920060.png

In my understanding, you want to use Single or Bulk as a slicer and to calculate the Calculate the ShippedQty with the largest number of rows separately. Modify your formula to:

Mode_ShippedQty =
VAR _T =
    TOPN (
        1,
        ADDCOLUMNS (
            VALUES ( ShippedOrders2022_Query[ShippedQty] ),
            "Frequency", CALCULATE ( COUNT ( ShippedOrders2022_Query[ShippedQty] ) )
        ),
        [Frequency], 0
    )
RETURN
    MAXX ( _T, [ShippedQty] )

Get the correct result.

vkalyjmsft_1-1656482248007.png

vkalyjmsft_2-1656482261965.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

Your measure mainly used a TOPN function, which will return a row in your formula instead of a value.

I create a sample. Single or Bulk is a calculated column according to your description.

vkalyjmsft_0-1656481920060.png

In my understanding, you want to use Single or Bulk as a slicer and to calculate the Calculate the ShippedQty with the largest number of rows separately. Modify your formula to:

Mode_ShippedQty =
VAR _T =
    TOPN (
        1,
        ADDCOLUMNS (
            VALUES ( ShippedOrders2022_Query[ShippedQty] ),
            "Frequency", CALCULATE ( COUNT ( ShippedOrders2022_Query[ShippedQty] ) )
        ),
        [Frequency], 0
    )
RETURN
    MAXX ( _T, [ShippedQty] )

Get the correct result.

vkalyjmsft_1-1656482248007.png

vkalyjmsft_2-1656482261965.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Ashish_Mathur
Super User
Super User

Hi,

Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
tamerj1
Super User
Super User

Hi @Anonymous 

please try

Mode_ShippedQty =
TOPN (
1,
ADDCOLUMNS (
ALLSELECTED ( ShippedOrders2022_Query[ShippedQty] ),
"Frequency", CALCULATE (COUNT ( ShippedOrders2022_Query[ShippedQty] ) )
),
[Frequency], 0
)
Anonymous
Not applicable

@tamerj1  @Ashish_Mathur   Below is the calculated column I mentioned.    

 

My desire is to be able to have the mode calculated separately for Bulk  or  for Single.   

 

So if there are 30 rows.   I want to determine what the mode is for all of the rows that are bulk, and all of the rows that are single.    So if there was 10 rows for single, and the shipped quantity of "7" occurs on 6 out of 10 rows, then the mode would be 7.  

 

Single or Bulk =
SWITCH (
TRUE (),
 
CONTAINSSTRINGEXACT ( ShippedOrders2022_Query[Description], "40pk" ), "Bulk",
CONTAINSSTRINGEXACT ( ShippedOrders2022_Query[Description], "96PK" ), "Bulk",
"Single"
)

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.