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

Need Help!! How to calculate different row items

hi, 

 

I am trying to Calculate the difference between waves, but I am running into some issues. These waves are in rows and a text format ( not date ). I also want to select a specific wave and automatically show the "vs. prior wave" number. Thank you so much!!

 

Perezjav_0-1599954136526.png

 

1 ACCEPTED SOLUTION

Hi @Perezjav 

I build a table like yours to have a test.

1.png

Firstly, you need to transform your table by unpivot column like pranit828  replied before. (Select three wave columns)

Result:

2.png

Then build a Slicer Table.

 

Slicer = VALUES('Table'[Wave])

 

Add an Index column in Table.

 

Index = RANKX(FILTER('Table','Table'[Category]=EARLIER('Table'[Category])),'Table'[Wave],,ASC)

 

Build a measure and build a matrix visual to achieve your goal.

 

vs Prior Wave = 
VAR _select =
    SELECTEDVALUE ( Slicer[Wave] )
VAR _selindex =
    CALCULATE (
        SUM ( 'Table'[Index] ),
        FILTER (
            'Table',
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Wave] = _select
        )
    )
VAR _current =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Index] = _selindex
        )
    )
VAR _prior =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Index] = _selindex - 1
        )
    )
RETURN
    _current - _prior

 

Result is as below.

Default:

3.png

Select Wave2/Wave3 in Slicer:

5.png6.png

You can download the pbix file from this link: Need Help!! How to calculate different row items

 

Best Regards,

Rico Zhou

 

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

4 REPLIES 4
Anonymous
Not applicable

@Perezjav 

can you post the expected output for more information.

Hi @Anonymous 

 

The expected output is "vs. Prior wave" number. It is highlighted in the picture.

Thank you

Hi @Perezjav 

I build a table like yours to have a test.

1.png

Firstly, you need to transform your table by unpivot column like pranit828  replied before. (Select three wave columns)

Result:

2.png

Then build a Slicer Table.

 

Slicer = VALUES('Table'[Wave])

 

Add an Index column in Table.

 

Index = RANKX(FILTER('Table','Table'[Category]=EARLIER('Table'[Category])),'Table'[Wave],,ASC)

 

Build a measure and build a matrix visual to achieve your goal.

 

vs Prior Wave = 
VAR _select =
    SELECTEDVALUE ( Slicer[Wave] )
VAR _selindex =
    CALCULATE (
        SUM ( 'Table'[Index] ),
        FILTER (
            'Table',
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Wave] = _select
        )
    )
VAR _current =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Index] = _selindex
        )
    )
VAR _prior =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Category] = MAX ( 'Table'[Category] )
                && 'Table'[Index] = _selindex - 1
        )
    )
RETURN
    _current - _prior

 

Result is as below.

Default:

3.png

Select Wave2/Wave3 in Slicer:

5.png6.png

You can download the pbix file from this link: Need Help!! How to calculate different row items

 

Best Regards,

Rico Zhou

 

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

 

pranit828
Community Champion
Community Champion

Hi @Perezjav 

To start with unpivot all three wave column and then use the earlier function to get the previous wave data.

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

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