Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
lafakios
Helper I
Helper I

How to add dynamic rows with an average value based on a group of rows

Hi,

 

I would like to create a visual like the following one.

 

WANTED VISUAL

 

       Not To Be Shown
 HigherOrLowerThanAverageItemA 1.4Average of the last 3 ItemAItemA 1.3 ItemA 1.2ItemA 1.1ItemA 1.0
Param1L021235
Param2L91412141612
Param3L142647
Param4H63.3333412
Param5H302020103014

 

Considering the structure of the underlying data set (can be found at the bottom of the post), a matrix visual could be used for that purpose. 

 

RowsParam_id
ColumnsItem_ID
Valuesvalue

 

When doing so, it is not easy to add the columns highlighted in blue font color.

 

I have already spent some time trying to find ways to build the wanted visual. I have also experimented to pivot the param_id column in the data set. So far I have not been able to get to a solution.

 

Any advice or tips would be more than welcome.

 

Thanks in advance for your help!

 

Regards,

Akis

 

DATA SET

 

Item_IDparam_idvalue
ItemA 1.3 Param11
ItemA 1.3 Param212
ItemA 1.3 Param32
ItemA 1.3 Param43
ItemA 1.3 Param520
ItemA 1.2Param12
ItemA 1.2Param214
ItemA 1.2Param36
ItemA 1.2Param43
ItemA 1.2Param510
ItemA 1.1Param13
ItemA 1.1Param216
ItemA 1.1Param34
ItemA 1.1Param44
ItemA 1.1Param530
ItemA 1.0Param15
ItemA 1.0Param212
ItemA 1.0Param37
ItemA 1.0Param412
ItemA 1.0Param514
ItemB 1.3 Param120
ItemB 1.3 Param22
ItemB 1.3 Param314
ItemB 1.3 Param46
ItemB 1.3 Param53
ItemB 1.2Param12
ItemB 1.2Param214
ItemB 1.2Param36
ItemB 1.2Param43
ItemB 1.2Param510
ItemB 1.1Param13
ItemB 1.1Param216
ItemB 1.1Param34
ItemB 1.1Param44
ItemB 1.1Param530
ItemB 1.0Param116
ItemB 1.0Param24
ItemB 1.0Param34
ItemB 1.0Param430
ItemB 1.0Param55
1 ACCEPTED SOLUTION

@lafakios 

pls see the attachment below

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
lafakios
Helper I
Helper I

Hi,

 

Would the fact that no more responses have been provided mean that this is not feasible to perform in PowerBI 🙂 ?

lafakios
Helper I
Helper I

Average of the last 3 per param = {ItemA 1.3(param.value) + ItemA 1.2(param.value) + ItemA 1.1(param.value)} / 3

 

example: Average of the last 3 of param1 = {1 + 2 + 3} / 3 = 2

 

HigherOrLowerThanAverage per param = If( ItemA 1.4(param.value) >= Average of the last 3 per param, "H", "L")

 

example: HigherOrLowerThanAverage of param1 = L {0 < 2}

where is the item 1.4 data? I can't see in it in your sample data.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you for building a PBIx report and sharing it, this actually does provide the needed functionality!

 

One of the key calculated columns is the below:

Column = CALCULATE(DISTINCTCOUNT('Table'[Item_ID]),FILTER('Table','Table'[param_id]=EARLIER('Table'[param_id])&&'Table'[item]=EARLIER('Table'[item])&&'Table'[Item_ID]>=EARLIER('Table'[Item_ID])))
 
I did a quick check if the above logic can scale to more than 4 items e.g. to support also items like itemA 1.5, 1.6, 1.7 etc. and the check result was successful.
 
One minor drawback of the current solution is that the column header in the visual refers to a measure name and not to the actual item represented by the measure e.g. itemA 1.4, 1.3, 1.2

The itemA 1.4 data were missing in the sample table.

Please find below the updated sample table including itemA 1.4

 

Item_IDparam_idvalue
ItemA 1.4 Param10
ItemA 1.4 Param29
ItemA 1.4 Param31
ItemA 1.4 Param46
ItemA 1.4 Param530
ItemA 1.3 Param11
ItemA 1.3 Param212
ItemA 1.3 Param32
ItemA 1.3 Param43
ItemA 1.3 Param520
ItemA 1.2Param12
ItemA 1.2Param214
ItemA 1.2Param36
ItemA 1.2Param43
ItemA 1.2Param510
ItemA 1.1Param13
ItemA 1.1Param216
ItemA 1.1Param34
ItemA 1.1Param44
ItemA 1.1Param530
ItemA 1.0Param15
ItemA 1.0Param212
ItemA 1.0Param37
ItemA 1.0Param412
ItemA 1.0Param514
ItemB 1.3 Param120
ItemB 1.3 Param22
ItemB 1.3 Param314
ItemB 1.3 Param46
ItemB 1.3 Param53
ItemB 1.2Param12
ItemB 1.2Param214
ItemB 1.2Param36
ItemB 1.2Param43
ItemB 1.2Param510
ItemB 1.1Param13
ItemB 1.1Param216
ItemB 1.1Param34
ItemB 1.1Param44
ItemB 1.1Param530
ItemB 1.0Param116
ItemB 1.0Param24
ItemB 1.0Param34
ItemB 1.0Param430
ItemB 1.0Param55

@lafakios 

pls see the attachment below

 

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




AmiraBedh
Super User
Super User

Can you please share the logic of your calculations ? For HigherOrLowerThanAverage and Average of the last 3 ?

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors