Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
eddd83
Resolver I
Resolver I

count rows by month without creating relationship

In my table:

X-High, High, Medium and Low are all measures.

Total is just a measure summing the previous 4 measures.

All-running total is the running total for the first 4 measures.

X-high + high running total is just the running total for X-high + high.

 

may 16 running total 1.PNG

 

The measures are calculating values in the following data table.

 

may 16 running total 2.PNG

 

I also want to create another measure counting the rows in a specific month. For the above data table, that would be 12 for January 2019. Based on my internet research, I'm supposed to use the following:

 

Month Count = CALCULATE(COUNT(data[due date]);USERELATIONSHIP(data[due date];DimDate[Date]))

and ensure that there's a relationship between my data table and the date table.

 

 

However, not only does that above measure not work, turning on the table relationship completely screws up the first table with my other measures (high, medium, low, etc).

 

Help?

1 ACCEPTED SOLUTION

I believe you can create a virtual relationship bewteen tables using the TREATAS function (never used it myself; so far have managed with inactive relationships and USERELATIONSHIP). Sorry I can't be of further help, but might be worth scouting the internet.

 

Try here for example: TREATAS by enterprisedna.com





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

8 REPLIES 8
v-chuncz-msft
Community Support
Community Support

@eddd83 ,

 

You may try the measure below.

Measure =
COUNTROWS (
    FILTER (
        testData,
        DATEDIFF ( testData[Due Date], MAX ( 'Date'[Date] ), MONTH ) = 0
    )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The measure in the last post didn't work either.

 

may 21 results.PNGmay 21 results 2.PNG

 

I ended up using power query in Excel and the queries auto-run whenever the file opens. Then using various array formulas, I produced my desired result.

 

I believe you can create a virtual relationship bewteen tables using the TREATAS function (never used it myself; so far have managed with inactive relationships and USERELATIONSHIP). Sorry I can't be of further help, but might be worth scouting the internet.

 

Try here for example: TREATAS by enterprisedna.com





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Ashish_Mathur
Super User
Super User

Hi,

Create a relationship from the Due Date column of the Data Table to the Date column of the Date Table.  In the Date Table, write this calculated column formula to extract the Month: Month = FORMAT(Calendar[Date],"mmmm").  To your visual, drag Month from the Date Table.  Write this measure

Measure1 = COUNTROWS(Data)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

As I mentioned in my first post, is there a way of doing this without creating a relationship, because this screws up the calculations in my original table. Even creating a relationship and leaving it inactive will screw up the calculation

 

Or do I just need to figure a way of calculating my orignal table differently?

That is really strange that it is messing up your table when you leave it inactive. That is what I would do. 

 

Can I assume you are leaving the relationship with the Task Completion Date active when you create the inactive relationship with the Due Date? 

When creating my original table, there were zero relationships in my data model.

BTW here's my file that you can use. 

 

one drive link for my pbix file

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.