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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kaikai24
Frequent Visitor

Create a New Column in the One Side of a One-Many Relationship

Hello everyone,

 

I have a one-to-many relationship between the 'Main' table and the 'LastSixMonthCount' table on the column 'Classification'. The 'Main' table has all the customer reviews. Now I am trying to create a new column in the 'LastSixMonthCount' table, which calculates the counts of customer reviews for each classification in the last six months. My DAX is below, but it does not work. Does anyone have any ideas?

 

kaikai24_0-1730916729279.png

kaikai24_1-1730916739667.png

kaikai24_2-1730917002354.png

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @kaikai24 ,

 

try like:

CountReview =

COUNTROWS(

    FILTER(

        RELATEDTABLE(main),

        main[datelast] >= EDATE(TODAY(), -6)

    )

)

View solution in original post

3 REPLIES 3
Poojara_D12
Super User
Super User

Hey @kaikai24 

Please try using this DAX:-

LastSixMonthReviewCount = 
VAR SixMonthsAgo = TODAY() - 180
RETURN
    CALCULATE(
        COUNTROWS('Main'),
        'Main'[Classification] = 'LastSixMonthCount'[Classification],
        'Main'[ReviewDate] >= SixMonthsAgo
    )

 

Please let me know if it works for you.

Regards,

Poojara.

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Anonymous
Not applicable

Hi @kaikai24 ,

I create two tables as you mentioned and I also create a relationship between them.

vyilongmsft_0-1730944875902.png

vyilongmsft_1-1730944897502.png

vyilongmsft_2-1730944948303.png

Then I create a new calculated column and here is the DAX code.

CountReview = 
CALCULATE (
    COUNT ( 'Main'[DA ReviewId] ),
    FILTER (
        'Main',
        AND (
            'Main'[Classification] = EARLIER ( 'LastSixMonthCount'[Classification] ),
            DATEDIFF ( 'Main'[Date of latest rating], TODAY (), MONTH ) <= 6
        )
    )
)

vyilongmsft_3-1730945099995.png

 

 

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.

FreemanZ
Super User
Super User

hi @kaikai24 ,

 

try like:

CountReview =

COUNTROWS(

    FILTER(

        RELATEDTABLE(main),

        main[datelast] >= EDATE(TODAY(), -6)

    )

)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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