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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ediaz795
Regular Visitor

Get sum of rows based on multiple criteria and relationships

Hello,

 

I'm getting my first project on PBI after my company gave me licence.

 

In a nutshell, I have 2 numbers: Forecasted Time and Actual Time. Sometimes we get bigger actual than forecasted, and viceversa. So I need to measure the Actual Time % Forecasted (we internally call it "Allocation"). The data it's given by Day of Week and half-hour intervals.

 

Below an sketch that we made on Excel:

 

ediaz795_0-1631341659436.png

 

The DAX Measure for Actual Time % Forecasted is this:

=IF(
([Sum of ActualMinutes]/[Sum of ForecastedMinutes]) <= 0,
0,
[Sum of ActualMinutes]/[Sum of ForecastedMinutes]
)

 

Also, we measure the trend of how the numbers move with the following table:

 

ediaz795_1-1631341918589.png

 

The DAX measure for Actual Time % Forecasted Trend is this: 

=CALCULATE([Actual_Time_%_Forecasted],

FILTER(ALLSELECTED('Calendar'[Day Of Week Number]), 'Calendar'[Day Of Week Number] <= MAX('Calendar'[Day Of Week Number])),

FILTER(ALLSELECTED(Interval[Interval]), Interval[Interval] <= MAX(Interval[Interval]))

)

 

Now, on Power BI, this is the model that I've been working on

 

ediaz795_2-1631342556614.png

 

I have the datasets the sources connected, the indexes for Day of Week and Half-Hour intervals and category for our data. And I'm stuck in here, I'm not able to mimic the DAX formulas that we use on the Excel prototype on Power BI DAX measures.

 

I think this is so basic and dummy, but I hope to learn much about it.

 

Any ideas how can I solve this?

 

PS. on the Excel book, we have slicers to filter in/out the data that we are analyzing , but I think after solving the above, I'll be able to add filters or buttons to the Power BI Report

 

ediaz795_3-1631343016031.png

 

1 REPLY 1
daxer-almighty
Solution Sage
Solution Sage

@ediaz795 

 

If you have a working power pivot model in Excel, then how come you are not able to replicate such a model in PBI? Where's the problem? Because despite all the info I can't see it... except that your measures are not optimal and in fact too rigid since they only work correctly with certain attributes on the axes, whereas they should work correctly with any attribute that comes from the time-related dimensions.

 

For instance, why do you think that

([Sum of ActualMinutes]/[Sum of ForecastedMinutes]) <= 0, 

could be less than 0? Are the two measures not non-negative integers?

 

Secondly, you are calculating an expression twice in the first measure instead of once by using a variable.

Thirdly, the second measure should be written in a different way using ALLSELECTED as a CALCULATE modifier, not as a table function. The way it's written also bans proper calculations on the full date/time axis.

 

Many things to attend to here but I'd really want to know why you can't replicate a working PP model from Excel.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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