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

To get the Selected and previous to the selected Value

Hi Team,

I am new to PowerBI and getting familier with the tool and DAX.

I have the following Data:

QtrIndex
2019Q11
2019Q22
2019Q33
2019Q44

 

I have a slicer on Qtr.

Need to get the selected Slicer Value and its previous value.

Example:

Selected slicer value is "2019Q3"

Result on Card should be : "2019Q3 & 2019Q2"

Result on card if no slicer Selection: "2019Q4 & 2019Q3" (Max value and its previous value)

 

Thanks in advance

 

 

 

1 ACCEPTED SOLUTION
Pragati11
Super User
Super User

Hi @VR_123 ,

 

You can follow the steps below to achieve the desired result:

  1.  The sample data used is 

viz1.png

2. Create a column as follows:

   viz2.png

3. Create the following calculated column:

viz3.png

 

4. Create the following measure:

viz4.png

5. Move the above created measure "DISPLAYVALUECARD" to a card visual and create a slicer with QUARTER column:

viz5.png

This shows the dafault value which you asked for when nothing is selected in the filter.

 

6. Let's select a value:

viz6.png

Desired result is displayed.

Similarly, if you check other filter selections, the desired value is displayed in the card.

 

Hope this solution helps.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

3 REPLIES 3
ash123
Regular Visitor

Hi ,

 

There is also another way of achieving the functionality you are looking for to be inplemented in your report.

 

Step 1 :  Create a measure to capture previous Qtr  based on your selection .

 

Previous_Qtr =
IF (
ISFILTERED ( 'Table'[Qtr] ),
LOOKUPVALUE ( 'Table'[Qtr], 'Table'[Index], MAX ( 'Table'[Index] ) - 1 )
)

 

Step 2 : Create another measure select_measure which you have to place in the card. Here when you  have selected any Qtr then that qtr and previous qtr will be shown else last qtr and its previous qtr will be shown.

 

select_measure =
IF (
    ISFILTERED ( 'Table'[Qtr] ),
    MAX ( 'Table'[Qtr] ) & " & " & [Previous_Qtr],
    LOOKUPVALUE ( 'Table'[Qtr], 'Table'[Index], MAX ( 'Table'[Index] ) ) & " & "
        LOOKUPVALUE ( 'Table'[Qtr], 'Table'[Index], MAX ( 'Table'[Index] ) - 1 )
)

Also, It is suggested not to use calculated column as it hampers performance.

 

Hope it helps.

 

Thanks.

Kaushlendra Mishra 

www.powerbitalks.com

Linkedin: https://www.linkedin.com/in/kaushlendra-mishra-49627310/

 

Pragati11
Super User
Super User

Hi @VR_123 ,

 

You can follow the steps below to achieve the desired result:

  1.  The sample data used is 

viz1.png

2. Create a column as follows:

   viz2.png

3. Create the following calculated column:

viz3.png

 

4. Create the following measure:

viz4.png

5. Move the above created measure "DISPLAYVALUECARD" to a card visual and create a slicer with QUARTER column:

viz5.png

This shows the dafault value which you asked for when nothing is selected in the filter.

 

6. Let's select a value:

viz6.png

Desired result is displayed.

Similarly, if you check other filter selections, the desired value is displayed in the card.

 

Hope this solution helps.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Hi @VR_123 ,

 

If my solution helped you, can you please mark and accept it as a solution for others to refer in future.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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