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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
donodackal
Helper I
Helper I

Help creating measure to filter data

Hello

Is there a way I can filter the data from the below table based on how many locations a product is sold? For instance, I would like to filter the data visualised by:

  • Products sold at only one location
  • Products sold at two locations
  • Product sold at three locations
  • Products sold at all four locations.

Also, Is there a way I can add a filter to my dashboard where if I select two or more locations specifically, the data is filtered to products sold specifically to both or more locations selected (excludes products sold just to one of the selected locations)?

 

Table Name: Product Sales
Product IDNo of UnitsTotal ValueSale DateLocation
Product 11050015/07/2022Location 1
Product 2525016/07/2022Location 2
Product 3210017/07/2022Location 1
Product 4420018/07/2022Location 1
Product 1210019/07/2022Location 2
Product 2420020/07/2022Location 3
Product 3315021/07/2022Location 2
Product 4840022/07/2022Location 1
Product 1735023/07/2022Location 3
Product 2735024/07/2022Location 2
Product 3420025/07/2022Location 3
Product 4420026/07/2022Location 1
Product 1735023/07/2022Location 4
Product 2735024/07/2022Location 2
Product 3420025/07/2022Location 3
Product 4420026/07/2022Location 1
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1658057971452.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_0-1658070835886.png

CNENFRNL_1-1658070876679.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @donodackal,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1658057971452.png

 

For fun only, a showcase of powerful Excel worksheet formula,

CNENFRNL_0-1658070835886.png

CNENFRNL_1-1658070876679.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Jos_Woolley
Solution Sage
Solution Sage

Hi,

First create a separate, single-column table to be used as a filter which comprises integers from one up to the maximum number of locations you would like to filter for (four, in your example). Assuming this table and its only column are both named 'Unique Location Count', create this measure:

 

MyMeasure =
VAR UniqueLocationCount =
    SELECTEDVALUE( 'Unique Location Count'[Unique Location Count] )
VAR MyTable =
    ADDCOLUMNS(
        SUMMARIZE( 'Product Sales', 'Product Sales'[Product ID] ),
        "Unique Locations",
            CALCULATE(
                DISTINCTCOUNT( 'Product Sales'[Location] ),
                ALLEXCEPT( 'Product Sales', 'Product Sales'[Product ID] )
            )
    )
RETURN
    SUMX( MyTable, 0 + ( [Unique Locations] = UniqueLocationCount ) )

 

which can then be dragged into the filters pane for your main visual and set equal to 1.

Of course, you could also dynamically derive the table 'Unique Location Count' from your dataset instead of creating it statically.

Regards

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.