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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
AlvRomero
Regular Visitor

How to iterate a table filtering by multiple columns of the same table

Hi everyone, I hope you are having a nice day

I was working on my report when I encountered the following problem. I have a table like the following:

 

PersonIdCategory             Date                                Value
15

2023-12-01

10
16

2023-12-01

8
15

2023-12-02

6
35

2023-12-01

5
44

2023-12-01

1


What I need is to get, in a measure if possible, the value for each DATE in category 5. That is, I would like the final result to be as follows:

PersonIdDate                          New Measure
12023-12-0110
12023-12-026
32023-12-015

 

Thank you very much in advance for your help,

 

Best regards

3 ACCEPTED SOLUTIONS
v-yaningy-msft
Community Support
Community Support

Hi, @AlvRomero 

 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1708567619363.png

 

 

Measure:

 

MEASURE =

VAR _5 =

    SELECTEDVALUE ( 'Table'[Category] )

VAR _value =

    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Category] = _5 ) )

RETURN

    IF ( _5 = 5, _value )

 


Best Regards,
Yang
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 in the Power BI Forum

 

 

View solution in original post

AlvRomero
Regular Visitor

Hi, thank you for your response.

When I apply the solution that you have provided me what happens is that it adds the sum of all the category to all the people, that is to say, the result that we obtain is the following one:

(I will put the result of the measure that you have provided me and the one we are looking for)

AlvRomero_0-1708588581280.png


Thanks for your input, I hope we can find a solution to the problem,

Best Regards




View solution in original post

Hi, @AlvRomero 

You can change the SUM to Max, everything works fine on my side of the implementation, do you have any other filters on your data in Power BI Desktop that affect the implementation results?

 

vyaningymsft_0-1708594072467.png

Measure:

 

MEASURE1 = 
VAR _5 =
    SELECTEDVALUE ( 'Table'[Category] )
VAR _value =
    CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Category] = _5 ) ,ALL('Table'))
RETURN
    IF ( _5 = 5, _value )

 

 

 

Best Regards,
Yang
Community Support Team

View solution in original post

3 REPLIES 3
AlvRomero
Regular Visitor

Hi, thank you for your response.

When I apply the solution that you have provided me what happens is that it adds the sum of all the category to all the people, that is to say, the result that we obtain is the following one:

(I will put the result of the measure that you have provided me and the one we are looking for)

AlvRomero_0-1708588581280.png


Thanks for your input, I hope we can find a solution to the problem,

Best Regards




Hi, @AlvRomero 

You can change the SUM to Max, everything works fine on my side of the implementation, do you have any other filters on your data in Power BI Desktop that affect the implementation results?

 

vyaningymsft_0-1708594072467.png

Measure:

 

MEASURE1 = 
VAR _5 =
    SELECTEDVALUE ( 'Table'[Category] )
VAR _value =
    CALCULATE ( MAX ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Category] = _5 ) ,ALL('Table'))
RETURN
    IF ( _5 = 5, _value )

 

 

 

Best Regards,
Yang
Community Support Team

v-yaningy-msft
Community Support
Community Support

Hi, @AlvRomero 

 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1708567619363.png

 

 

Measure:

 

MEASURE =

VAR _5 =

    SELECTEDVALUE ( 'Table'[Category] )

VAR _value =

    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', 'Table'[Category] = _5 ) )

RETURN

    IF ( _5 = 5, _value )

 


Best Regards,
Yang
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 in the Power BI Forum

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Top Kudoed Authors