Forum Discussion

JonKho's avatar
JonKho
Frequent Visitor
2 years ago
Solved

Unable to perform COUNT for flag value

Hi all

 

I am trying to do a count within the measure shown below:

 

Flag = IF(
    MAX([Created_Date])<=NOW()&&
    MAX([Created_Date])>=NOW()-12/24,1,0
    )
 

I have been trying to use CALCUATE function or COUNT/COUNTROWS (For columns only) functions as it will not work.

 

Please refer to the sample data shown below for more information:

 

Reference: https://community.fabric.microsoft.com/t5/Desktop/last-12-hours-only/td-p/1828455

 

Thank you for the help on this matter.

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi JonKho ,,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    Flag =
    IF (
        MAX ( 'Table'[Created_Date] ) <= NOW ()
            && MAX ( 'Table'[Created_Date] )
                >= NOW () - 1,
        1,
        0
    )

    Finally I create another measure and get what you want.

    Measure = COUNTROWS(FILTER('Table','Table'[Flag]=1))

     

     

     

     

    Best Regards

    Yilong Zhou

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JonKho ,,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    Flag =
    IF (
        MAX ( 'Table'[Created_Date] ) <= NOW ()
            && MAX ( 'Table'[Created_Date] )
                >= NOW () - 1,
        1,
        0
    )

    Finally I create another measure and get what you want.

    Measure = COUNTROWS(FILTER('Table','Table'[Flag]=1))

     

     

     

     

    Best Regards

    Yilong Zhou

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