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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rdvasisht
Frequent Visitor

locking a measure/cell in power bi for comparison

 how would i compare each cell of a column with a measure value? so in excel we can lock a cell like this: $F$4 and then compare it with each cell of a column. how would we do this in power bi? the value of the measure is subject to change.

the value of the measure should update when group it with values in another column.

 

for eg.

productRevenueSitedatemeasure value
A-2canadasept 3, 2022-4.89
B13USASept 1, 2022-4.89
C-11ItalySept 2, 2022-4.89
A12CanadaSept 6, 2022-4.89
B-3USASept 4, 2022-4.89
C4ItalySept 12, 2022-4.89

measure that i have has value = -4.89

the measure is calculated using: (stddev.s(revenue)*sqrt(1-0.89))*-1

above table is coorect when not filtered.

 

what is want is create a column by comparing 'Revenue' with ' Measure'. the column will have value "1" if less than measure else "0".

following table is what i want when filter for product. for e.g. you see that the measure value is updated based in the value of the reveunue

productRevenueSitedatemeasure value
A-2canadasept 3, 2022-3.28
A12CanadaSept 6, 2022-3.28

 

when i created the calculated column using the measure value and applied some filter, the value of the measure does not change. i want that to update based on filter on date, site and product.

 

 

 

any help is appreciated

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rdvasisht ,

Please try below steps:

1. below is my test table

Table2:

vbinbinyumsft_0-1663911820740.png

Table3:

Table 3 = VALUES('Table 2'[Product])

vbinbinyumsft_1-1663911843059.png

2. create some meaure with below dax formula

Avg Price =
VAR cur_product =
    SELECTEDVALUE ( 'Table 3'[Product] )
VAR tmp =
    FILTER ( ALL ( 'Table 2' ), 'Table 2'[Product] = cur_product )
RETURN
    IF (
        ISBLANK ( cur_product ),
        AVERAGEX ( ALL ( 'Table 2' ), [Price] ),
        AVERAGEX ( tmp, [Price] )
    )
Measure2 =
VAR cur_price =
    SELECTEDVALUE ( 'Table 2'[Price] )
RETURN
    IF ( cur_price > [Avg Price], "> Avg", "< Avg" )
Measure3 =
VAR cur_product =
    SELECTEDVALUE ( 'Table 3'[Product] )
VAR cur_p =
    SELECTEDVALUE ( 'Table 2'[Product] )
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table 2'[Product] ),
        FILTER ( ALL ( 'Table 2' ), 'Table 2'[Product] = cur_product )
    )
RETURN
    IF ( cur_p IN tmp || ISBLANK ( cur_product ), 1, 0 )

3. add a slicer visual with Table3[Product] column, add a table visual with Table2's  column , add Measure3 to table visual filter pane

vbinbinyumsft_2-1663912156320.png

Animation18.gifPlease refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Syndicate_Admin
Administrator
Administrator

I have a similar situation, but I'm not very experienced in Power BI, I have a table and I have a total that I'd like to leave fixed something like $F 4 in Excel, but I've already tried several functions and it doesn't give me the expected result.

ebarbosa_bogota_0-1708044336014.png

The column in red is the one that the power BI throws at me, and the column in green is how the percentages should look in a straight way.

How to solve this with a formula in power bi

Any help I will be grateful.

Atte ERNESTO BARBOSA, Bogota Colombia

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @rdvasisht ,

You can try below steps, i provide a sample for you.

1. my test table

Table:

vbinbinyumsft_0-1663832379225.png

 

2. create measure with below dax formula

Median Price = MEDIANX(ALL('Table'),[Price])
Measure =
VAR cur_price =
    SELECTEDVALUE ( 'Table'[Price] )
RETURN
    IF ( cur_price > [Median Price], "> median", "< median" )

3.  add a table visual with two measure and fields

vbinbinyumsft_1-1663832478508.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous , thanks for reply. say i have average instead of Median. now if i have multiple row for  product in table and want to filter for only fruit. it does not update the average price for selected filter. how can i have updated value of median/avg price when filterer? when filtered the average price should be only for what has been filtered. your help is appreciated

Capture.PNG.

you see in the above photo the average price should be 15 since it is filtered for fruit only.

but the following photo shows right avg as nothing has been filtered.

Capture.PNG

Anonymous
Not applicable

Hi @rdvasisht ,

Please try below steps:

1. below is my test table

Table2:

vbinbinyumsft_0-1663911820740.png

Table3:

Table 3 = VALUES('Table 2'[Product])

vbinbinyumsft_1-1663911843059.png

2. create some meaure with below dax formula

Avg Price =
VAR cur_product =
    SELECTEDVALUE ( 'Table 3'[Product] )
VAR tmp =
    FILTER ( ALL ( 'Table 2' ), 'Table 2'[Product] = cur_product )
RETURN
    IF (
        ISBLANK ( cur_product ),
        AVERAGEX ( ALL ( 'Table 2' ), [Price] ),
        AVERAGEX ( tmp, [Price] )
    )
Measure2 =
VAR cur_price =
    SELECTEDVALUE ( 'Table 2'[Price] )
RETURN
    IF ( cur_price > [Avg Price], "> Avg", "< Avg" )
Measure3 =
VAR cur_product =
    SELECTEDVALUE ( 'Table 3'[Product] )
VAR cur_p =
    SELECTEDVALUE ( 'Table 2'[Product] )
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table 2'[Product] ),
        FILTER ( ALL ( 'Table 2' ), 'Table 2'[Product] = cur_product )
    )
RETURN
    IF ( cur_p IN tmp || ISBLANK ( cur_product ), 1, 0 )

3. add a slicer visual with Table3[Product] column, add a table visual with Table2's  column , add Measure3 to table visual filter pane

vbinbinyumsft_2-1663912156320.png

Animation18.gifPlease refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@Anonymous thanks for your help. it worked

HoangHugo
Solution Specialist
Solution Specialist

Hi,

yes you can, put your measure into calculate column (this will be a new column have constant value of measure) to compare in row contex, like this

 

calculate column =

var meaure_column = your measure

return your comparsion

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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