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! Request now

Reply
vaishalisah
Regular Visitor

Multiply rows of two category based on different datetime frequency

Hello,

 

I need the following scenario to be achieved in Direct query mode. I was able to achieve it in Data Import mode but in Direct Query I see that the transformations and DAX formulas are quite limited.

 

Scenario:

I have a table with data of two of more categories. The data of two categories is logged at different frequency of time. I need to create a report or visualization which displays the product of values of two categories based on the timestamp value. For the timestamps where the less frequent data doesn't have a value, the most recent value available should be used. Following is the sample of data and expected output:

 

TimeStampCategoryCat_Value
2017-03-19 07:00:00.000A10
2017-03-19 07:15:00.000A10.5
2017-03-19 07:30:00.000A10.3
2017-03-19 07:00:00.000B5.1
2017-03-19 07:05:00.000B5.3
2017-03-19 07:10:00.000B5.4
2017-03-19 07:15:00.000B5.2
2017-03-19 07:20:00.000B5.6
2017-03-19 07:25:00.000B5
2017-03-19 07:30:00.000B5.5

 

Output Expected  
 Product (A,B)
2017-03-19 07:00:00.0005.1 * 10
2017-03-19 07:05:00.0005.3 * 10
2017-03-19 07:10:00.0005.4 * 10
2017-03-19 07:15:00.0005.2 * 10.5
2017-03-19 07:20:00.0005.6 * 10.5
2017-03-19 07:25:00.0005 * 10.5
2017-03-19 07:30:00.0005.5 * 10.3

 

 

Please suggest on how it can be done.

 

Thanks,

Vaishali

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @vaishalisah,

 

I need the following scenario to be achieved in Direct query mode. I was able to achieve it in Data Import mode.

To achieve this requirement in direct query mode, you need to use query to do it. In your scenario, which datasource are you using?

 

For the relational table, you ca use the query below.

select a.TimeStamp,CAST(a.Cat_Value as varchar)+'*'+cast((select MAX(b.Cat_Value) from test5 b where b.Category='A' and b.TimeStamp<=a.TimeStamp) as varchar) as [Product(A,B)] from test5 a where a.Category='B'

Capture.PNG

 

Regards,

Charlie Liao

View solution in original post

2 REPLIES 2
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @vaishalisah,

 

I need the following scenario to be achieved in Direct query mode. I was able to achieve it in Data Import mode.

To achieve this requirement in direct query mode, you need to use query to do it. In your scenario, which datasource are you using?

 

For the relational table, you ca use the query below.

select a.TimeStamp,CAST(a.Cat_Value as varchar)+'*'+cast((select MAX(b.Cat_Value) from test5 b where b.Category='A' and b.TimeStamp<=a.TimeStamp) as varchar) as [Product(A,B)] from test5 a where a.Category='B'

Capture.PNG

 

Regards,

Charlie Liao

vaishalisah
Regular Visitor

Hello,

 

Any thought on this? I need help on this as I am new to Power BI and trying to analyze the feasibility of replacing our current system with PowerBI. I tried creating measure but could not think of any way to refer back to the current/previous row value in that context.

 

I also tried to do pivot by category and then apply some logic to multiply. Again, couldn't find any way to get the values in columns with no values for the specific time stamp. Fill down/Up is not available for live connection queries.

 

I need to conclude whether this scenario is achievable in PowerBI or not.

 

Please help.

 

Regards,

Vaishali

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.

Top Kudoed Authors