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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
HowAreYou
New Member

Iterative row calculation

Hello community!

 

Could you please help me to understand and create suitable calculation for this case?

I have fotovoltaics where I generate electricity and I have also 2 locations where I consume electricity.

 

Data looks like this - 2 tables with DateTime relation:

DateTimeLocationConsumption (kW) DateTimeGeneration (kW)
1.1.24 9:00A3,25 1.1.24 9:000,25
1.1.24 9:15A3 1.1.24 9:150,25
1.1.24 9:30A3,5 1.1.24 9:300,5
1.1.24 9:45A4 1.1.24 9:451
1.1.24 10:00A3,75 1.1.24 10:003
1.1.24 10:15A4 1.1.24 10:156
1.1.24 10:30A3 1.1.24 10:307
1.1.24 10:45A2,75 1.1.24 10:458
1.1.24 11:00A3 1.1.24 11:002
1.1.24 11:15A4,75 1.1.24 11:151
1.1.24 11:30A5,5 1.1.24 11:300,25
1.1.24 11:45A6 1.1.24 11:450,5
1.1.24 12:00A3 1.1.24 12:000,25
1.1.24 9:00B0,25   
1.1.24 9:15B0,5   
1.1.24 9:30B0,25   
1.1.24 9:45B0,75   
1.1.24 10:00B1   
1.1.24 10:15B0,5   
1.1.24 10:30B0   
1.1.24 10:45B0   
1.1.24 11:00B1   
1.1.24 11:15B0,25   
1.1.24 11:30B1   
1.1.24 11:45B0,25   
1.1.24 12:00B0,5   

 

The output I need should look like:

DateTimeLocationConsumption (kW)% Covered
1.1.24 9:00A3,257,69%
1.1.24 9:15A38,33%
1.1.24 9:30A3,514,29%
1.1.24 9:45A425,00%
1.1.24 10:00A3,7580,00%
1.1.24 10:15A4100,00%
1.1.24 10:30A3100,00%
1.1.24 10:45A2,75100,00%
1.1.24 11:00A366,67%
1.1.24 11:15A4,7521,05%
1.1.24 11:30A5,54,55%
1.1.24 11:45A68,33%
1.1.24 12:00A38,33%
1.1.24 9:00B0,25100,00%
1.1.24 9:15B0,550,00%
1.1.24 9:30B0,25100,00%
1.1.24 9:45B0,75100,00%
1.1.24 10:00B1100,00%
1.1.24 10:15B0,5100,00%
1.1.24 10:30B0100,00%
1.1.24 10:45B0100,00%
1.1.24 11:00B1100,00%
1.1.24 11:15B0,25100,00%
1.1.24 11:30B125,00%
1.1.24 11:45B0,25100,00%
1.1.24 12:00B0,550,00%

 

Additionally I would like to have a slicer with predefined multipliers which can multiply fotovoltaics generation based on selected value. Lets say that table above is default but I can choose 2, 3, 4, 5 etc. to multiply its generation by that number.

 

Im having the issue that calculated columns arent affected by this slicer and I wasnt able to create a measure which could calculate the above % coverage based on each individual row evaluation. It always sums everyhting together and doesnt count individually on 15 minutes basis.

 

Any ideas appreciated! 

Thank you

5 REPLIES 5
Anonymous
Not applicable

Hi @HowAreYou ,

 

You can try the following expression.

 

TotalGen =

SUM('Table 2'[Generation (kW)]) * SELECTEDVALUE(Multipliers[Value])

 

TotalCon =

SUM('Table'[Consumption (kW)])

 

Measure =

VAR _div = DIVIDE([TotalGen],[TotalCon],1)

RETURN

IF(_div > 1, 1, _div)

vkaiyuemsft_0-1728631694916.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

 

Hello @Anonymous, 

 

Thank you for providing the above. Thats not exactly it. Expected output should be:

HowAreYou_0-1728885361469.png

It can be achieved by creating calculated column. The issue is how to apply multiplier to calculated column since its being calculated during the refresh and measure (or slicer) cannot be used within calc column.

 

Calc column is:

Covered (Multiplier 1) = IF ( 'Table'[Consumption (kW)] - related('Table 2'[Generation (kW)]) < 0, 'Table'[Consumption (kW)], related('Table 2'[Generation (kW)]))

 

The question is how to apply multiplier in this case? (Please note that there might be 1000 multipliers in reality so having 1000 columns is not right approach.

 

Anonymous
Not applicable

Hi @HowAreYou ,

 

Thanks for the reply from Kedar_Pande , please allow me to provide another insight: 

 

You can try the following steps.


1. Create a table of calculations to be subsequently used as slicer values.

Multipliers = GENERATESERIES(1, 5, 1)

 

2. create the measure.

% Covered =
VAR TotalGen = CALCULATE(SUM('Table 2'[Generation (kW)]),FILTER(ALL('Table 2'),'Table 2'[DateTime] = MAX('Table'[DateTime])))
VAR TotalCons = SUM('Table'[Consumption (kW)])
VAR Div = DIVIDE(TotalGen * SELECTEDVALUE(Multipliers[Value]),TotalCons,1)
RETURN
IF(Div > 1, 1, Div)

 

The final result is shown below.

vkaiyuemsft_0-1728540548033.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Hello @Anonymous! @Kedar_Pande !

 

Thank you both for providing the guide. It works well. One additional question. 

In my provided example there are just few timestamp rows but in reality there are thousands, maybe milions of rows.

Is it possible to have a measure which could evaluate % Covered based on every row and then make a sum (for example I want to group % Covered based on months (and for example see that 30% of month can be covered while not going into granilarity of 15 mins detail)).

 

*In your current solution calculation works only if dimmension is in the lowest granularity level

 

Sample of grouping issue:

HowAreYou_0-1728586994052.png

Variable "TotalGen" in "% Covered" measure takes only "max('Table'[DateTime])" one row.

 

Kedar_Pande
Super User
Super User

Establish a relationship between the two tables on the DateTime field.

Create a Table for Multipliers:

Multipliers = DATATABLE("Multiplier", INTEGER, {{1}, {2}, {3}, {4}, {5}})

Add a slicer to your report using this new Multipliers table.

Measure for Adjusted Generation:

Adjusted Generation (kW) = 
VAR SelectedMultiplier = SELECTEDVALUE(Multipliers[Multiplier], 1)
RETURN
SUMX(GENERATIONTABLE, GENERATIONTABLE[Generation (kW)] * SelectedMultiplier)

Measure for Percentage Covered

% Covered = 
VAR CurrentConsumption = SUMX(CONSUMPTIONTABLE, CONSUMPTIONTABLE[Consumption (kW)])
VAR CurrentGeneration =
CALCULATE(
[Adjusted Generation (kW)],
FILTER(GENERATIONTABLE, GENERATIONTABLE[DateTime] = MAX(CONSUMPTIONTABLE[DateTime]))
)
RETURN
IF(CurrentConsumption > 0, DIVIDE(CurrentGeneration, CurrentConsumption, 0), 0)

Format the % Covered measure as a percentage in Power BI by going to the measure properties and setting the data type to percentage.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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