Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Help with measures and AutoExists

Hi,

 

I have a factless fact table called Milestone and a dimension table called Project. These look as follows and are joined off the PID column.

 

Project

PIDP_name
1Proj A
2Proj B

 

Milestone

PIDMIDDate
1123/03/2019
1229/03/2019
1316/04/2019
14 
15 
16 
17 
218/03/2019
2211/03/2019
23 
24 

 

I have a simple measure which counts the number of milestones for a project. It is as follows:

 

Measure = 
CALCULATE(
    COUNTROWS(Milestone),
    ALL(Milestone[MID])
)

 

 

When I create a table visual consisting of Milestone[PID], Milestone[MID], [Measure]. I get the expected result. Each PID, MID combination exists and the measure correctly counts the number of milestones.

 

Result Table Visual

Milestone[PID]Milestone[MID][Measure]
117
127
137
147
157
167
177
214
224
234
244

 

When I remove Milestone[PID] and replace it with the Project[P_name] I get the correct result but with combinations which should not exists (PID2 does not have milestones 5,6,7 ). From my understanding this is caused by the AutoExist feature not operating on columns in different tables and effectively creating a cross join.

 

Result Table Visual

Project[P_name]Milestone[MID][Measure]
Proj A17
Proj A27
Proj A37
Proj A47
Proj A57
Proj A67
Proj A77
Proj B14
Proj B24
Proj B34
Proj B44
Proj B54
Proj B64
Proj B74

 

 

How can I write the measure to get a result where only the correct combinations exist? I have found many articles explaining this "feature" but nothing explaining how to get around it. Creating a similar measure in my production model creates cross joins so big that Power Bi can't handle it.

 

Note that adding the P_name column to Milestone table is not possible and nor is including Milestone[PID] in the result visual.

 

Desired Result Visual

Project[P_name]Milestone[MID][Measure]
Proj A17
Proj A27
Proj A37
Proj A47
Proj A57
Proj A67
Proj A77
Proj B14
Proj B24
Proj B34
Proj B44

 

Many thanks!

  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous ,

     

    You can try to use following measure to achieve your requirement:

    Measure = 
    CALCULATE(
        COUNTROWS(Milestone),
        ALLSELECTED(Milestone[MID]),
        VALUES(Milestone[PID])
    )

     

    Regards,

    Xiaoxin Sheng

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You can try to use following measure to achieve your requirement:

    Measure = 
    CALCULATE(
        COUNTROWS(Milestone),
        ALLSELECTED(Milestone[MID]),
        VALUES(Milestone[PID])
    )

     

    Regards,

    Xiaoxin Sheng