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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
powerbilover123
Regular Visitor

Getting value from another table (timeperiod)


I have a measure that takes every unique timeperiod value from a dimension-table and then calculates what value falls in that timeperiod in the fact-table and counts them. I want to create a graph showcasing the timeperiod values on x and the count on y. But the value is off.

The problem is that the X-axis only counts one row on the starting value and not the other periods of time. Does anybody know how to fix this? To illustrate: Starting time is 15:00 and ending time 17:00, it only counts one value at 15:00 instead of counting 1 value at 16:00 and 1 at 17:00. The measure counts the total correct, but the problem occurs when trying to showcase it on a graph

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @powerbilover123 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"dim"

vnuocmsft_0-1713491133626.png

 

"fact"

vnuocmsft_1-1713491151958.png

 

Create a measure. Counts the values in the fact table for that time period.

 

count num = 
var _dimtime = SELECTEDVALUE('dim'[Time])
var _facttime = SELECTEDVALUE('fact'[Time])
RETURN
IF(
    _dimtime = _facttime, 
    CALCULATE(COUNTROWS('fact'), FILTER('fact', 'fact'[Time] = MAX('fact'[Time]))), 
    0
)

 

Here is the result.

 

vnuocmsft_2-1713491306857.png

 

 

Regards,

Nono Chen

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

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file.  Show the expected result in a Table format.


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

Hi @powerbilover123 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"dim"

vnuocmsft_0-1713491133626.png

 

"fact"

vnuocmsft_1-1713491151958.png

 

Create a measure. Counts the values in the fact table for that time period.

 

count num = 
var _dimtime = SELECTEDVALUE('dim'[Time])
var _facttime = SELECTEDVALUE('fact'[Time])
RETURN
IF(
    _dimtime = _facttime, 
    CALCULATE(COUNTROWS('fact'), FILTER('fact', 'fact'[Time] = MAX('fact'[Time]))), 
    0
)

 

Here is the result.

 

vnuocmsft_2-1713491306857.png

 

 

Regards,

Nono Chen

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

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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 Solution Authors
Top Kudoed Authors