Forum Discussion

cdebackere's avatar
cdebackere
Resolver I
1 year ago
Solved

Change aggregation from default on numeric column

I have a data model with a fact and 2 dimentions, each linked over a factless fact table, since the relations are n-m I now go further on 1 dimention, let's say room. Here is a mini dataset ex...
  • cdebackere's avatar
    cdebackere
    1 year ago

    Hi Anonymous 

     

    Based on your information I looked into the model again ... to find out that you are right (yeah right 😁 ), but only for the model shown above.

    Now after some more testing, I would dare to say that there are 2 possible solutions:

    • either keep the model as is above, and use

    rooster.hours.room = sumx(reservationsreservations[res_info2] * COUNTROWS(RELATEDTABLE(roomReservations)))

    • or adapt the model and set the 'room-roomReservations' relation to filter in both directions as well. In that case you can also use the formula below, since filtering will cascade from reservations over roomReservations into rooms. So the RELATEDTABLE function isn't limited to follow links to 'the next' table, but to the 'chain of related, but filtered tables':

    rooster.hours.room = sumx(reservationsreservations[res_info2] * COUNTROWS(RELATEDTABLE(rooms)))

     

    So the first formula works in both case, due to the 'reservation-rooomReservation' filtering in both directions anyhow.

    Wether the one datamodel is better than the other: depends on how you want your model/measures/filters to work in your particular situation. The one is not bettter than the other.

    If in doubt: I learned that the best way to define that: make a mini model with very limited but 'situation-representative' data and try.

     

    Hope this helps someone else

     

    C.