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

SelectedValue Question

Hi everyone, 

I'm trying to create a measure using selectedvalue and the problem is that for some cases, as I don't have any data for the case listed the result of selected value is blank. 

For example:


semana 123.png

 

In the case listed above, as the COSA, LATAM and ROW markets using the selected value do not have any line with the data 44 that is filtered, the result generated is blank.

 

So, this problem ends up generating another key problem that I'm trying to solve, which is:

 

I need to create a measure that I can filter numbers of weeks (example listed was week 44) where when I create the formula with selectedvalue -1 the result as it was blank does not generate the expected result that would be 43 (result of 44-1 ).

 

semana 123.png

Does anyone know how to solve this problem?

 

Regards,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi there.

 

As you said, i'm trying to get a result from the previus week using the currently week as parameter. The thing is that when the currently week has no value (I dont have any lines with any values, of course, the result for the sum is 0 and also, the parameter that i'm looking is blank) which means that as the measure is looking for the parameter - 1. As the parameter is 0 or blank the result is Measure, filter by something where the result is -1.

Example:
CALCULATE([MEASURE], Number Week = Week - 1 (As the week is blank or 0, the result will always be -1).

The way the I found to solve it right now is create another table with all the posibles weeks and also create a Primary Key with Week&Market (is this case market is COSA, LATAM and ROW). And with that I will always have a week number and the measure will work just fine.

 

But, I dont know if this is the best way. Unfortunetly was the way that i found to fix the problem that i had.

 

Regards, 

View solution in original post

6 REPLIES 6
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, it seems that you are trying to get the sum of the values of a term from the previous week of the current week? So what should the result be when it doesn't have the previous week?

 

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.

 

Anonymous
Not applicable

Hi there.

 

As you said, i'm trying to get a result from the previus week using the currently week as parameter. The thing is that when the currently week has no value (I dont have any lines with any values, of course, the result for the sum is 0 and also, the parameter that i'm looking is blank) which means that as the measure is looking for the parameter - 1. As the parameter is 0 or blank the result is Measure, filter by something where the result is -1.

Example:
CALCULATE([MEASURE], Number Week = Week - 1 (As the week is blank or 0, the result will always be -1).

The way the I found to solve it right now is create another table with all the posibles weeks and also create a Primary Key with Week&Market (is this case market is COSA, LATAM and ROW). And with that I will always have a week number and the measure will work just fine.

 

But, I dont know if this is the best way. Unfortunetly was the way that i found to fix the problem that i had.

 

Regards, 

DimaMD
Solution Sage
Solution Sage

Hi @Anonymous  You can try such an event

IF( ISBLANK([SelectesValue]), BLANK(),[SelectesValue - 1])

Screenshot_10.jpg


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
Anonymous
Not applicable

Hi.

Well, the thing is that in this case o wont have the value "43" for COSA, LATAM and ROW. 


I need this value because a have a formula with calculate and it has a filter with [week num] = Selectedvalue -1.

 

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel and measure looks like, but I assume COSA, LATAM, and ROW have more than one value in the filter context that is shown on the report page.

Please check the link down below how SELECTEDVALUE DAX function returns.

 

SELECTEDVALUE function - DAX | Microsoft Learn

 -> The value when the context for columnName has been filtered down to one distinct value only. Else, alternateResult or BLANK.

 

Try using MAX or MIN DAX function and check whether it suits your requirement.

 

I hope this helps.

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

yes!

The example that i gave before is just the beginnig of what i'm woking on.

 

With the measure Selectedvalue -1 i have one more measure with calculate that is Calculate(sum(XXX), week num = Selectedvalue - 1.

 

The problem is as the selectedvalue -1 is blank or -1 and is not 43 as it should be i cant get the right result.

 

Regards, 

 

 

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.

Top Solution Authors