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

Help with measure if is filtered

Hi all,

 

Taking account the attached pbix scenerio i need help to compose a new measure that complete some requirements:

1)By default alway we have to select a product.If nothing is selected one card have to show "Select a product" and the other have to select the max date of the column "Fecha".

 

2)When the produt is select, the card with the text "Select a product" have to show the max commericalWeek of the table "semanacomercialventa" taking accout the max of the fecha.

 

3)If the "tipoproducto" have more thatn one result as is showed in the image. The card should select the max fecha and also the max Week by default.

cromero2416_0-1664890421066.png

 

4)If is selected any other commercial week of the list of options with data should be selected the week selected and the max date.

 

I hope you can help me, I'm really stucked with this.

 

Here also attached some test i've been performance without any result.

 

ExamplePBI.zip

 

 

 

CommercialWeekSelected = 
IF(
    ISFILTERED('semanacomercialventa'[commericalWeek]),
    CALCULATE(
        MAX('semanacomercialventa'[commericalWeek]),
        FILTER(
            'semanacomercialventa',
            'semanacomercialventa'[Index] = MAX('semanacomercialventa'[Index])
        )
    ),
    
        "Select a product"
    )

 

 

 

 

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @cromero2416 ,

According to your description, I download your sample and here's my solution.

CommercialWeekSelected =
IF (
    ISFILTERED ( 'Product'[tipoproducto] ),
    MAXX (
        FILTER (
            'ventas',
            'ventas'[fecha]
                = MAXX (
                    FILTER (
                        'ventas',
                        'ventas'[typoventa] = SELECTEDVALUE ( 'Product'[tipoproducto] )
                    ),
                    'ventas'[fecha]
                )
        ),
        'ventas'[commericalWeek]
    ),
    "Select a product"
)

Get the correct result.

Requirement1:

vkalyjmsft_0-1665545094907.png

Requirement2,3:

vkalyjmsft_1-1665545205189.png

Requirement4:

vkalyjmsft_2-1665545226561.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

6 REPLIES 6
v-yanjiang-msft
Community Support
Community Support

Hi @cromero2416 ,

According to your description, I download your sample and here's my solution.

CommercialWeekSelected =
IF (
    ISFILTERED ( 'Product'[tipoproducto] ),
    MAXX (
        FILTER (
            'ventas',
            'ventas'[fecha]
                = MAXX (
                    FILTER (
                        'ventas',
                        'ventas'[typoventa] = SELECTEDVALUE ( 'Product'[tipoproducto] )
                    ),
                    'ventas'[fecha]
                )
        ),
        'ventas'[commericalWeek]
    ),
    "Select a product"
)

Get the correct result.

Requirement1:

vkalyjmsft_0-1665545094907.png

Requirement2,3:

vkalyjmsft_1-1665545205189.png

Requirement4:

vkalyjmsft_2-1665545226561.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

cromero2416
Frequent Visitor

Hi,

 

Up.

 

Thanks

@cromero2416 , You might have to use

 

CommercialWeekSelected =
IF(
calculate(ISFILTERED('semanacomercialventa'[commericalWeek]), allselected()) ,
CALCULATE(
MAX('semanacomercialventa'[commericalWeek]),
FILTER(
'semanacomercialventa',
'semanacomercialventa'[Index] = MAX('semanacomercialventa'[Index])
)
),

blank()
)

 

for that message we keep an image behind and try to use conditional background formatting,

 

with #FFFFFF00 , transparent color and #FFFFFF white color

 

 

cromero2416
Frequent Visitor

Hi all,

 

Could someone help with this?

 

Thanks in advance

hi @amitchandak 

 

mmm i think no , i don't need to sum anything. Is more related to how the dates and comercial weeks are showed in the card taking account the filters in the report. You have the example attached .

 

Thanks in advance

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.