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

Measure to calculate visual level % of a table visual

Hellow Gurus,

 

I have below requirement. I need previous row as a measure on my table visual.

 

Measure for previous row.png

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@mahoneypat ,

 

thanks for the reply.

 

I need this calculation to happen at the visual level not in the dataset. what would be the measure.

View solution in original post

mahoneypat
Employee
Employee

Here is a measure that should work:

 

Prev Amt =
VAR __thissubtask =
    MIN ( Table[SubTask ID] )
VAR __thisSUM =
    SUM ( Table[Amount] )
VAR __prevamt =
    CALCULATE (
        SUM ( Table[Amount] ),
        ALLEXCEPT ( Table, Table[Program ID], Table[Task ID] ),
        Table[SubTask ID] = __thissubtask - 1
    )
RETURN
    IF ( ISBLANK ( __prevamt ), __thisSUM, __prevamt )

 

For the ratio, just use DIVIDE with your orignal measure and this measure.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
mahoneypat
Employee
Employee

Here is a measure that should work:

 

Prev Amt =
VAR __thissubtask =
    MIN ( Table[SubTask ID] )
VAR __thisSUM =
    SUM ( Table[Amount] )
VAR __prevamt =
    CALCULATE (
        SUM ( Table[Amount] ),
        ALLEXCEPT ( Table, Table[Program ID], Table[Task ID] ),
        Table[SubTask ID] = __thissubtask - 1
    )
RETURN
    IF ( ISBLANK ( __prevamt ), __thisSUM, __prevamt )

 

For the ratio, just use DIVIDE with your orignal measure and this measure.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Employee
Employee

If this does not need to be dynamic, you can do it in the query editor by adding an Index column starting at zero and then adding a custom column with a formulat like this

 

= try #"Added Index"[ColumnWIthDesiredValue]{[Index]-1} otherwise null

 

Where #"Added Index" is the name of the previous step and your desired column name goes in the [ ].  The try otherwise part is just to avoid an error on the very first value (which has no previous one).  Once you have the column, you can then write a simple measure to get the previous result into your visual (same aggregation as current result, and just replace column name).

 

If you do need it to be dynamic (e.g., respond to slicers, work with different colums), I think you'll need to provide more details on needed functionality and context.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat ,

 

thanks for the reply.

 

I need this calculation to happen at the visual level not in the dataset. what would be the measure.

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.