Forum Discussion

vinayguptak81's avatar
vinayguptak81
Frequent Visitor
3 years ago

DAX Count not working

Hi everyone,

I am running into an issue and need some guidance.

Situation:  I have a handful of stores that I would like to count based on the Invoice Date selected, but excluded if they were closed.

For example:

The Active Store in Table 1 is coming from Table 2, but it brings up all the stores.  So what I am trying to achieve is, if I selected Invoice dates: 05/2023 - 03/2023, then the Active store counts should be YearMonth >= 03/2023 === 262, not 367.

 

Any help is highly appreciated.  Thank you.

 

 

5 Replies

  • Wilson_'s avatar
    Wilson_
    Icon for Memorable Member rankMemorable Member

    Hi Vinay,

     

    What does your data model look like?

    • vinayguptak81's avatar
      vinayguptak81
      Frequent Visitor

      Hi Wilson,

      Table 1 is detail and Table 2 is roll-up.  The relationship between the two tables is Entity join.

      • Wilson_'s avatar
        Wilson_
        Icon for Memorable Member rankMemorable Member

        Vinay,

         

        It sounds like at the very least you would benefit from a dates/calendar table (and perhaps from an entity dimension table). Not the quick fix you were perhaps looking for but it soudns like you would benefit long term from learning about data modeling; a proper data model would make this easier to build than having to overcomplicate the DAX. SQLBI is a phenomenal resource and they have a free intro to data modeling course available.


        ----------------------------------
        If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

  • Hi vinayguptak81 ,

     

    Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

     

    Refer to:

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,

    Jianbo Li

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