Forum Discussion

CrudenBoy's avatar
CrudenBoy
Frequent Visitor
6 years ago
Solved

Issue with ALLSELECT

Hi

I am fairly new to DAX and am having a problem doing an advance calculation. Without going into the full-blown explanation of cohort Surval Rate calculation, I have tried to focus on a small using which I think stems from an ALLSELECT statement I use.

 

If someone can anyone please tell me what I am going wrong I would be extremely grateful!

 

The table below explains my issue. In summary, the measure GC2 works but I have a problem with the measure GC3. I see this is because the measure X3 returns ZEROs in each row and not 0.816 in each row. However, the calculation works in measure X2 

 

The formulas are:

GC2=X2* Y2

GC3=X3* Y3

Where X2 and X3 are generated by the following formulas

X2 = CALCULATE([GC1],
FILTER(Allselected(SurvivalRate),
SurvivalRate[GradeCode]=1))

 

and 

X3 = CALCULATE([GC2],
FILTER(Allselected(SurvivalRate),
SurvivalRate[GradeCode]=2))

You can open this link to my example file which I have published on my Onedrive account, but this table attempts to explain the issue.

 

  • CrudenBoy  What is it you are ultimately trying to acheive? Do GC0, GC1, etc actually need to be in separate columns? I'm wondering if you could use the EARLIER function to create a series of calculated columns in a GradeCode table that has each grade code listed once? 

    https://blog.enterprisedna.co/how-to-use-the-earlier-function-in-power-bi-a-dax-tutorial/

    Iterators might also help to lock in the row and table context that each measure needs to calculate within, rather than how they are now which is floating across the data model and recalculating depending on how you setup your table.

    https://www.microsoftpressstore.com/articles/article.aspx?p=2449191&seqNum=3

    EARLIER and Iterators might help you get what you need. 

     

    Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

     

    If you found this post helpful, please give Kudos.

    I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

    https://sites.google.com/site/allisonkennedycv

  • Thank you very much for your feedback Anonymous AllisonKennedy  and vivran22 and let me apologise for my limited description of my problem. Alison's post was very useful as it made me read up about the filter context and row context and I have managed to make progress.

     

4 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Community Champion

    CrudenBoy  What is it you are ultimately trying to acheive? Do GC0, GC1, etc actually need to be in separate columns? I'm wondering if you could use the EARLIER function to create a series of calculated columns in a GradeCode table that has each grade code listed once? 

    https://blog.enterprisedna.co/how-to-use-the-earlier-function-in-power-bi-a-dax-tutorial/

    Iterators might also help to lock in the row and table context that each measure needs to calculate within, rather than how they are now which is floating across the data model and recalculating depending on how you setup your table.

    https://www.microsoftpressstore.com/articles/article.aspx?p=2449191&seqNum=3

    EARLIER and Iterators might help you get what you need. 

     

    Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

     

    If you found this post helpful, please give Kudos.

    I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

    https://sites.google.com/site/allisonkennedycv

  • Anonymous's avatar
    Anonymous
    Not applicable
    Without explaining the logic behind your measures... you can easily forget about anyone giving you an answer to your problem.

    Best
    D
    • CrudenBoy's avatar
      CrudenBoy
      Frequent Visitor

      Thank you very much for your feedback Anonymous AllisonKennedy  and vivran22 and let me apologise for my limited description of my problem. Alison's post was very useful as it made me read up about the filter context and row context and I have managed to make progress.