Forum Discussion

Marcos_Noguer's avatar
Marcos_Noguer
New Member
4 years ago

Filter a card by two dates

Hi everyone,

 

I need to filter a card by a date. The card has a mesure that calculates how many products are sold every day divided by the open shops of that day. 

UDLs = SUM('PRODUCT_MIX_RVC'[CANT_TRX])/SUM('Open shops'[Count])
 
What i want is to show the evolution in UDLs of the new products. So I have a table that hast de product id and the launch date of that product. The card has to show the UDLs the first day, another with the first week, first month, etc
 
What i have:

 

What i want:

 

 

So 'New Products[Launch date]' has to filter 'Open shops'[Date]' in the card.

 

Thank you!

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hey in this case, you need to hardcode measures for your card. Otherwise, the filter will apply to page visuals.

  • Hi Marcos_Noguer ,

     

    If your tables are like this:

     

    You can create three different cards to achieve your purpose, here is the DAX:

     

    UDLs(first day) =
    CALCULATE (
        DIVIDE ( SUM ( 'PRODUCT_MIX_RVC'[CANT_TRX] ), SUM ( 'Open shops'[Count] ) ),
        FILTER ( 'Open shops', [Date] = MAX ( 'New Products'[Launch date] ) )
    )
    
    UDLs(first week) =
    CALCULATE (
        DIVIDE ( SUM ( 'PRODUCT_MIX_RVC'[CANT_TRX] ), SUM ( 'Open shops'[Count] ) ),
        FILTER ( 'Open shops', [Date] = MAX ( 'New Products'[Launch date] ) + 7 )
    )
    
    UDLs(first month) =
    CALCULATE (
        DIVIDE ( SUM ( 'PRODUCT_MIX_RVC'[CANT_TRX] ), SUM ( 'Open shops'[Count] ) ),
        FILTER (
            'Open shops',
            MONTH ( [Date] )
                = MONTH ( MAX ( 'New Products'[Launch date] ) ) + 1
                && DAY ( [Date] ) = DAY ( MAX ( 'New Products'[Launch date] ) )
        )
    )

     

    Final output:

     

     

    If it isn't your expected output, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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