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

See when key Fabric features will launch and what’s already live, all in one place and always up to date. Explore the new Fabric roadmap

Reply
Danny090890
Frequent Visitor

Assign Count Value to a specific row in a Matrix

Dear Community,
I need your help.

I have a table in which I calculate the range of each article. Lets assume that I have two different itmes with to different ranges.

Item1 Range of 3 and Item2 with a Range of 1.

Now I have a second table. This table has different limits. Does are for example:
0>2<=
and
2><=5.

What I want to do know is,I wanto to make a distinctcount on the first table, namely on the Item column.And then,
bases on the range specified in table1, I would like to assign the count to the correct limit in table2.

Here is an example from my current Power BI with my goal.

Screenshot 2022-08-26 161507.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Danny090890 ,

 

Please try this measure.

Measure = 
VAR _selectvalue = SELECTEDVALUE('Table 1'[Border])
VAR _result_0_2 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=1&&'Table 2'[Range]<3)) + 0
VAR _result_2_5 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=3&&'Table 2'[Range]<6)) + 0
VAR _result_5_8 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=6&&'Table 2'[Range]<9)) + 0
VAR _result_8 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=9&&'Table 2'[Range]<999)) + 0
VAR _result = 
SWITCH(
    _selectvalue,
    "0><=2",_result_0_2,
    "2><=5",_result_2_5,
    "5><=8",_result_5_8,
    "8>",_result_8
)
RETURN
_result

vcgaomsft_0-1662021397855.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

3 REPLIES 3
Danny090890
Frequent Visitor

Hello,

 

thanks for the answer I will paste my table and solution bellow.

 

Like I said. I want to make a count on Itmes. And on the dependence of the range I want to asign the 

DISTINCTCOUNT of the items to the right border.

 

Data Table 1

BorderLowerUpper
0><=212
0><=223
2><=534
2><=545
2><=556
5><=867
5><=878
5><=889
8>9999

 

 

Data Table 2

ItemLocationRange
00253/00P3051
00253/00P2032
00171/03P3056
00563/02P30514
00129/00P2031
00129/00P3054

 

 

Solution (Output):

BorderCount of Itmes
0><=20
2><=52
5><=81
8>1

 

Solution Filter on Location P305:

BorderCount of Itmes
0><=21
2><=51
5><=81
8>1
Anonymous
Not applicable

Hi @Danny090890 ,

 

Please try this measure.

Measure = 
VAR _selectvalue = SELECTEDVALUE('Table 1'[Border])
VAR _result_0_2 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=1&&'Table 2'[Range]<3)) + 0
VAR _result_2_5 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=3&&'Table 2'[Range]<6)) + 0
VAR _result_5_8 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=6&&'Table 2'[Range]<9)) + 0
VAR _result_8 = CALCULATE(COUNT('Table 2'[Range]),FILTER('Table 2','Table 2'[Range]>=9&&'Table 2'[Range]<999)) + 0
VAR _result = 
SWITCH(
    _selectvalue,
    "0><=2",_result_0_2,
    "2><=5",_result_2_5,
    "5><=8",_result_5_8,
    "8>",_result_8
)
RETURN
_result

vcgaomsft_0-1662021397855.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

May 2025 Monthly Update

Fabric Community Update - May 2025

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