Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
Could somebody please help me in finishing my ISINSCOPE command?
I need the building name to sum the measure 'Total Bookable Hours' at the end, but it wont accept sum or sumx for the measure of bookable hours.
The Building needs to sum all of the rooms bookable hours on a top level of a matrix. So 400 instead of 200 in the file
Hierarchy = SWITCH(
TRUE(),
ISINSCOPE(
vw1[Room]), [Total Bookable Hours],
ISINSCOPE(
vw1[Building Name]),
))
Thanks
Liam
Solved! Go to Solution.
// Assuming that
// 1. There is a Building dimension that stores data about buildings.
// 2. There is a Room dimension that stores data about rooms.
// 3. There is a proper Calendar in the model.
// 3. There is a fact table Bookable Hours that for each day stores the bookable
// hours for the relevant combinations of buildings and rooms
// for each and every day...
// you can write this measure and it'll work correctly without
// any ISINSCOPE.
// Bear in mind that the filtering from dimensions to the fact table
// is one-way.
[Bookable Hours] =
CALCULATE(
SUM( 'Bookable Hours'[Hours] ),
LASTDATE( Calendar[Day] )
)
Best
D
// Assuming that
// 1. There is a Building dimension that stores data about buildings.
// 2. There is a Room dimension that stores data about rooms.
// 3. There is a proper Calendar in the model.
// 3. There is a fact table Bookable Hours that for each day stores the bookable
// hours for the relevant combinations of buildings and rooms
// for each and every day...
// you can write this measure and it'll work correctly without
// any ISINSCOPE.
// Bear in mind that the filtering from dimensions to the fact table
// is one-way.
[Bookable Hours] =
CALCULATE(
SUM( 'Bookable Hours'[Hours] ),
LASTDATE( Calendar[Day] )
)
Best
D
hi @Anonymous ,
I have everything set up properly now apart from the Bookable hours fact table which im struggling with.
With the layout that you suggested:
BuildingID | Room ID| Date| bookable hours
Would this require a calender with every day duplicated for every combination of room and building? This is the part I'm confused with.
Thanks
Liam
Hi @Anonymous ,
I think you may have misunderstood,
Thank you for your time
Hi @Anonymous ,
Thankyou for taking the time to reply, its much appreciated.
I guess below is where Ive been struggling with. Could you advise on a way this should be layed out?
Each day, building and room with hours for the day as columns?
3. There is a fact table Bookable Hours that for each day stores the bookable // hours for the relevant combinations of buildings and rooms // for each and every day...
Thanks
Liam
Yes. A fact table models the process you want to report on. In your case it'll look like this:
BuildingID | RoomID | Date | BookableHours | <Other columns as needed>
If you have any other layout, you should change it to this one. Achieving the above is simple with Power Query.
Best
D
@Anonymous
Okay thanks for confirming. In terms of getting the Building ID and Room ID over to its allocated Buidling, is there a smoother way to do this in power query than manually matching, or would this come out of the dim?
Thanks
Its all coming from a select statement with joins where all of these relations exist - but in SQL.
I was hoping there would be a way to calculate bookable hours and hours booked on a matrix without having to create all of my dimensions in Power BI, as these are the only calculations. My main issue is having bookable hours add up for the room to the building total.
If it cant be done it cant be done, and I will aim to recreate with new dims.
Thanks again for your help.
Liam
By the way... I've had a look at your file. The model is not correct. Please identify the business entities and then create dimensions out of them. Then connect them to a fact table that will store only measures about your process and keys to the dimensions. The fact table's columns must be hidden and only measures can be exposed; all slicing must be performed through dimensions. This is the correct star-schema design. If you do this, your DAX will be simple and fast. Do not create monster models like the one you've got right now because you'll suffer and in no time you'll be creating measures that will not only be inefficient but also wrong without you even noticing it.
Here are some materials to show you what a good model looks like:
https://www.youtube.com/watch?v=78d6mwR8GtA
https://www.youtube.com/watch?v=_quTwyvDfG0
Best
D
@Anonymous , there some missing items you have to fill
Hierarchy = SWITCH(
TRUE(),
ISINSCOPE(
vw1[Room]), [Total Bookable Hours],
ISINSCOPE(
vw1[Building Name]), [?], [?]
)
refer:https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/
Hi @amitchandak ,
Thanks for your reply. Yes I'm a bit confused as to what to put where the questions marks are.
In all of the examples I have seen with isinscope there has been a sum or divide after the isinscope i.e.
ISINSCOPE(
vw1[Room]), SUM(example),
However, mine already has a measure in place of the sum as below.
ISINSCOPE(
vw1[Room]), [Total Bookable Hours],
When I copy the measure into the second isinscope for the building name, this does not give the desired outcome.
User | Count |
---|---|
41 | |
27 | |
23 | |
18 | |
15 |
User | Count |
---|---|
54 | |
35 | |
19 | |
18 | |
15 |