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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculated column using data from multiple rows and columns

Hi, I've been stuck at a problem for a while now. I checked multiple other questions like mine but I wasn't able to find the right answer so I thought I'd ask. My situation looks like this: 

 

ValueSubIndexFrameIDDateSOLUTION
34THXY221.1.2020(BLANK)
505THXY221.1.2020(BLANK)
555THXY247.2.20201,0416...
441THXY247.2.20201,0416...
1206THXY247.2.20201,0416...
201THXY249.5.20203
605THXY249.5.20203
1006THXY249.5.20203
331THXY2511.6.2020...

 

I'm not sure if this is even possible in a single step but so far my ideas have only led to error messeges. I have the above data (with more rows which I'll leave out for clarity and more columns which are irrelevant to the calculation) and I am supposed to do the following: 

 

There are always 2 or 3 rows per date and FrameID. I need to calculate a number with the values of the rows for every FrameID using a formula and then enter that number in the solution column at the end (red column). The formula for a FrameID is SOLUTION = ((100 * value(row w/ the SubIndex 5))/value(row w/ the SubIndex 1))/value(row w/ the SubIndex 6). In the case of the FrameID THXY24 and Date 7.2.2020 this give us ((100*55)/44)120 = 1,0416... . In the case of there only being rows with the SubIndexes 1 and 5 given for a FrameID (as is the case for FrameID THXY22) then we cannot calculate anything so the entry should be blank. There may be more than 3 rows per FrameID but they will always be distinguishable by the date. I need to calculate the solution for each FrameID (if possible, otherwise I need to add the blank) and enter it in the solution column but I am completely stuck (I'm a novice). Is there any way to do this?

 

Any help wouls be appreciated, thanks!

2 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to approach this in a calculated column.  Please try this expression.

 

 

Result =
VAR index1 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 1
    )
VAR index5 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 5
    )
VAR index6 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 6
    )
RETURN
    IF ( NOT ( ISBLANK ( index6 ) ), 100 * DIVIDE ( index5, index1 ) / index6 )

 

 

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

Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=DIVIDE(DIVIDE(100*CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=5)),CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=1))),CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=6)))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@mahoneypat @Ashish_Mathur Thank you both. Both of your solutions worked perfectly. 

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

This calculated column formula works

=DIVIDE(DIVIDE(100*CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=5)),CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=1))),CALCULATE(SUM(Data[Value]),FILTER(Data,Data[FrameID]=EARLIER(Data[FrameID])&&Data[Date]=EARLIER(Data[Date])&&Data[SubIndex]=6)))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mahoneypat
Microsoft Employee
Microsoft Employee

Here is one way to approach this in a calculated column.  Please try this expression.

 

 

Result =
VAR index1 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 1
    )
VAR index5 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 5
    )
VAR index6 =
    CALCULATE (
        MIN ( Frame[Value] ),
        ALLEXCEPT ( Frame, Frame[FrameID], Frame[Date] ),
        Frame[SubIndex] = 6
    )
RETURN
    IF ( NOT ( ISBLANK ( index6 ) ), 100 * DIVIDE ( index5, index1 ) / index6 )

 

 

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


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.