Forum Discussion

JustinDoh1's avatar
JustinDoh1
Post Prodigy
5 years ago
Solved

My calculation does not work using variable (row context issue or something else?)

I am sharing my Pbix file here.

 

 

 

I posted a similar question yesterday, but this is little bit different (because I am trying to see whether somehow my logic has an error: ex "vNotEligibleStep1 = 1"). I am trying to express "if vNotEligibleStep1 case exisits". 

 

From the Pbix file that I am sharing, the issue is whenever we have an output (this case: Tina Turner = 1 & Michael Jaskson = 1) with one of three (Doe. D or Doe, W - where we have 'Not Eligible" as "Content" column), it gives a row context error (total does not sum up). I am not sure how to fix it or where the error is.

 

It is a mesasure called "Step1_0819" in the file.

 

Am I missing something on the calculation for VAR or how do I go about fixing where it is "vNotEligibleStep1 = 1" ?
Do I have to use Summarize function or how do I go about making the row context more obvious?

 
Thanks you so much for help!

 

 

 

 

  • PaulDBrown's avatar
    PaulDBrown
    5 years ago

    How about this for the variable:

     

    Var vNotEligibleStep1 = 
        COUNTROWS(
            FILTER(
                Data,
                Data[Consent] = "Not Eligible"  &&
                Data[Step] = 1
            )
        )

     

     

    This will return 1 for each row which meets the filtered criteria. You can now keep the switch function clause.

  • PaulDBrown's avatar
    PaulDBrown
    5 years ago

    Alternatively you can try:

    new measure = SUMX(Data, [Step 1_0819])

12 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    But Michael Jackson???

  • Anonymous Thank you for response. I would like to follow up if you could help me with any suggestions regards to how to fix the row context issue I am having. (BTW, I added "Tina Turner" in the Pbix file. Sorry I like oldies. 🙂  )

    • PaulDBrown's avatar
      PaulDBrown
      Community Champion

      I see you've changed the measure, since this step was always going to return 1

       

      Now the rogue variable returns a date, (specifically the MAX(Data[consentdate])based on the filters) but the first clause in the switch function checks to see if the variable returns 1 (a whole number; not a date). So I would assume the result is always false, since a date is never "1"...

       

       

      • JustinDoh1's avatar
        JustinDoh1
        Post Prodigy

        PaulDBrown Thank you for your help. Yea. I was modifying the original file as I put [ConsentDate] instead of [Consent].  I was/am trying to create a logic "exists".

         

        I guess " = 1" was silly. Here is what I am trying to say:  If on the Row context level, if this particular row meets this condition (Step =1 & Consent = "Not Eligible"), result should be "".