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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measure that condtional

Hi Expert,

 

I would like to have a measure, 

 

Example:

UserCodeRegionValue
AA1UK1
AA1US2
AA2DE3
BA1UK4
BA1US5
BA2DE6
BA2UK7
CA1UK8
CA1US9
CA1DE10
DA2UK11
DA2US12
DA2DE13

 

(conditional that can't create column)

 

Expected measure: [Sum of A2] for whose user have Code "A1", so that result

 

RegionSum of A2
UK7
DE9
total

16

 

 

 

Many thanks,

Simon

7 REPLIES 7
AlB
Super User
Super User

 Hi @Anonymous 

Your result doesn't seem to match what you describe. In any case, try this:

1. Place Region in the rows of a table visual

2. Place Code in a  slicer and select A1

3. Place this measure in the table visual

Measure = SUM( Table1[Value] )

4. You can add more slicers if you want to refine the sum further

 

Anonymous
Not applicable

@AlB 
Thanks for your reply, however that's not my expected answer. 
I've checked my expected result is corrrect, 
Please see the picture to be clear.

 

Raw table

image.png

 

Expected measure: [Sum of A2] for those user have "A1"

 

image.png

 

Many thanks

 

Ok, but then you'd need to explain better what you need. You are leaving user D out of the calculation. Is that what you want? If so, you just have to include another slicer for User and select users A, B, C only, leaving D out

Another option would be not to use this User slicer and embed the filtering in the measure

MeasureV2 =
CALCULATE ( SUM ( Table1[Value] ), Table1[User] <> "D" )

The first option is probably more versatile, since you can select the users of interest on the fly

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

 

Anonymous
Not applicable

@AlB  Thanks so much for your afford.

however it's not my expected answer as well

" You are leaving user D out of the calculation. Is that what you want?" - correct, but this should be done by calculation and not hard coding. Since user D doesn't have code "A1", so D have to be filtered out. 

To add Slicer is not my requirement as well.

 

1. Place Region in the rows of a table visual

2. Place this measure in the table visual

 

Measure-Sum of A2 =
SUMX (
    Table1;
    IF (
        Table1[Code] = "A2"
            && "A1" IN CALCULATETABLE ( DISTINCT ( Table1[Code] ); ALLEXCEPT ( Table1; Table1[User] ) );
        Table1[Value];
        0
    )
)

See it all at work in the attached file.

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Anonymous
Not applicable

@AlBMany thanks

I'm wondering that can your code here vary with the slicer changing?

 "A1" IN CALCULATETABLE ( DISTINCT ( Table1[Code] ); ALLEXCEPT ( Table1; Table1[User] ) )

It's expected dynamical

@Anonymous 

I'd need more details about what you exactly need. An example would be of great help

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors