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
AMAN560
Frequent Visitor

situation for making a dax in power bi

I have 3 columns name COL A, COL B, and COL C, All 3 are numeric column
sample data

Col A Col B Col C
1122
1343
217
2129
348
36710
412
523
524
621
62311
76515
7327

I am using Col A as a slicer on my page 

and have a card on my page with sum(COL B) I want to filter this card value such:

I want to take the sum of all the rows of COL B with values of COl C greater than or equal to the max of selected COl A in the slicer.

for instance, if I choose 3 on my slicer, the card should give me 242 (sum of COl B ) as I filter the rows of COl C which is greater than equal to 3.
Now, if I choose 5 on my slicer card should give me 204 (sum of COl B ) as I filter the rows of COl C which is greater than equal to 5.

 

currently I am using the following dax for this:

calculate(sum([COL b]), filter(allselected([COL C]),[COL C]>=calculate(max([COL A]),allselected([COL A])

 

2 ACCEPTED SOLUTIONS

@AMAN560 

1.PNG2.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

v-luwang-msft
Community Support
Community Support

Hi @AMAN560 ,

See the below ,new 1 is the measure you used ,and new 2 is mine:

new1 = 
CALCULATE (
    SUM ( [Col B ] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Col C]
            >= CALCULATE ( MAX ( 'Table'[Col A ] ), ALLSELECTED ( 'Table'[Col A ] ) )
    )
)
new2 = 
VAR TEST =
    SELECTEDVALUE ( 'Table'[Col A ] )
VAR TEST1 =
    CALCULATE (
        SUM ( 'Table'[Col B ] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Col C] >= TEST )
    )
RETURN
    TEST1

Return result:

vluwangmsft_0-1630037799424.pngvluwangmsft_1-1630037809859.png

And adjust your measure to the below,it will work:

new3 =
VAR test =
    CALCULATE ( MAX ( 'Table'[Col A ] ), ALLSELECTED ( 'Table'[Col A ] ) )
VAR test2 =
    CALCULATE (
        SUM ( 'Table'[Col B ] ),
        FILTER ( ALL ( 'Table' ), [Col C] >= test )
    )
RETURN
    test2

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

 

Best Regards

Lucien

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @AMAN560 ,

See the below ,new 1 is the measure you used ,and new 2 is mine:

new1 = 
CALCULATE (
    SUM ( [Col B ] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        [Col C]
            >= CALCULATE ( MAX ( 'Table'[Col A ] ), ALLSELECTED ( 'Table'[Col A ] ) )
    )
)
new2 = 
VAR TEST =
    SELECTEDVALUE ( 'Table'[Col A ] )
VAR TEST1 =
    CALCULATE (
        SUM ( 'Table'[Col B ] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Col C] >= TEST )
    )
RETURN
    TEST1

Return result:

vluwangmsft_0-1630037799424.pngvluwangmsft_1-1630037809859.png

And adjust your measure to the below,it will work:

new3 =
VAR test =
    CALCULATE ( MAX ( 'Table'[Col A ] ), ALLSELECTED ( 'Table'[Col A ] ) )
VAR test2 =
    CALCULATE (
        SUM ( 'Table'[Col B ] ),
        FILTER ( ALL ( 'Table' ), [Col C] >= test )
    )
RETURN
    test2

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

 

Best Regards

Lucien

ryan_mayu
Super User
Super User

@AMAN560 

pls try this

Measure = CALCULATE( sum('Table'[Col B ]),FILTER(all('Table'),'Table'[Col C]>=SELECTEDVALUE('Table'[Col A ])))




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




no it is not working on the sampledata itself

 

@AMAN560 

1.PNG2.PNG

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.