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

Percentual variation between weeks using SELECTEDVALUE problem

Hello everyone,

 

I've created a measure with the following DAX code:

semana pasada = CALCULATE(distinctcount('Table1'[Código Conflict]);
                    FILTER(ALL('Table1');
                    if(isfiltered('calendario'[weekday]);
                                            'Table1'[weekdayconfl] = SELECTEDVALUE('Table1'[weekdayconfl]) && 'Table1'[weeknumconfl] = SELECTEDVALUE('Table1'[weeknumconfl]) - 1;
                                            'Table1'[weeknumconfl] = SELECTEDVALUE('Table1'[weeknumconfl]) - 1)
))

 

Which combined with the following makes a percentual variation between weeks:

%  = divide(DISTINCTCOUNT(Table1[Código Conflict]) - [semana pasada];[semana pasada])

 

The code works well if you don't use any filter like you can see here:

2.PNG

 

But everything goes wrong when you use any filter or interaction:

3.PNG

 

Can someone help me on this?

 

Thank you really much.

 

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following measure to meet your requirement.

 

semana pasada =
CALCULATE (
    DISTINCTCOUNT ( 'Table1'[Código Conflict] ),
    FILTER (
        ALLSELECTED ( 'Table1' ),
        IF (
            ISFILTERED ( 'calendario'[weekday] ),
            'Table1'[weekdayconfl] = SELECTEDVALUE ( 'Table1'[weekdayconfl] )
                && 'Table1'[weeknumconfl]
                    = SELECTEDVALUE ( 'Table1'[weeknumconfl] ) - 1,
            'Table1'[weeknumconfl]
                = SELECTEDVALUE ( 'Table1'[weeknumconfl] ) - 1
        )
    )
)

 

Please try to  change ALL function to ALLSELECTED function

 

If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to OneDrive For Business and share the link here.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.