Forum Discussion

yohanp17190's avatar
yohanp17190
Frequent Visitor
3 years ago

Tableau to DAX help

I am trying to convert some dashboards that are in Tableau over to Power BI. I am still learning DAX functionalities but how would I convert the below calculated field to a DAX query?

SUM({ INCLUDE [Quarter]:
zn(COUNTD
(IF [Quarter]>='18-Q4' THEN
    if [TotalInteractionNumber]<> 'LEAD000001CH000001' and ([HoldFlag]=1) and [ActiveCampaignFlag]=1 then  [TotalInteractionNumber] END
  ELSE if [TotalInteractionNumber]<> 'LEAD000001CH000001' and ([HoldFlag]=1) then [TotalInteractionNumber] END
          END
  )
  )
   })

4 Replies

  • yohanp17190 , check if , this approch can help

    LOD Include (Level Of Details): https://youtu.be/nmBVc2fN6aU

     

    Use countx in this case with filter

     

    example

    CALCULATE(
    COUNTX(VALUES('Table'[Quarter]), [Quarter]),
    FILTER(
    ALL('Table'),
    [Quarter] < ( "18-Q4") &&
    [TotalInteractionNumber] <> "LEAD000001CH000001" &&
    [HoldFlag] = 1 &&
    [ActiveCampaignFlag] = 1
    )
    )

  • yohanp17190's avatar
    yohanp17190
    Frequent Visitor

    amitchandak Thank you for your quick response. I did try to plug in the query that you provided but I dont think it is giving me the right output. 
    I was given an explanation of what that calculated field is supposed to do. 

    It is supposed to count the [TotalInteractionNumber] field, which is an ID field, only once for each quarter along with the other filters that have been applied. 

    Would really appreciate it if you could help me with modifying your previous query. Ive been watching your videos and they have been really helpful.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi yohanp17190 ,

    Based on the formula, it appears that you are trying to count the number of unique TotalInteractionNumber values for each quarter, where the TotalInteractionNumber is not equal to 'LEAD000001CH000001', the HoldFlag is 1, and the ActiveCampaignFlag is 1 for quarters after '18-Q4', and where the TotalInteractionNumber is not equal to 'LEAD000001CH000001' and the HoldFlag is 1 for quarters before '18-Q4'.

     

    Please have a try.

    column=
    CALCULATE(
        COUNTROWS(
            FILTER(
                'Table',
                'Table'[TotalInteractionNumber] <> "LEAD000001CH000001" &&
                'Table'[HoldFlag] = 1 &&
                (
                    'Table'[ActiveCampaignFlag] = 1 &&
                    'Table'[Quarter] >= "18-Q4" ||
                    'Table'[Quarter] < "18-Q4"
                )
            )
        ),
        ALL('Table'[Quarter])
    )

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.