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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
h_l
Post Patron
Post Patron

New Measure, search and return

Hello everyone,

 

Can you please help to tell:

How to create measure to: 

Sum Table2[Clicks] for certain Unique [Table1]Campaign Page ID are cointained in Table2[Page] under certain [Table1]Action Week?

e.g. Sum Clicks for all Unique [Table1]Campaign Page ID in "Week10", or Sum Clicks for all Unique IDs in "Update Copy"

h_l_1-1622722710054.png

 

Table2:

h_l_0-1622723565249.png

 

 

 

Thanks.

H

1 ACCEPTED SOLUTION

HI @h_l,

I'd like to suggest you add a new calculated column to table2 to extract the fact page id:

PageID =
PATHITEM (
    SUBSTITUTE ( [Page], "/", "|" ),
    PATHLENGTH ( SUBSTITUTE ( [Page], "/", "|" ) )
)

Then you can use this field and the date range of the 'week number' to summary records.

Measure =
VAR currDate =
    MAX ( Table[Action Date] )
VAR _list =
    CALCULATETABLE (
        VALUES ( Table[Campaign Page ID] ),
        FILTER ( ALLSELECTED ( Table ), YEAR ( [Action Date] ) = currDate ),
        VALUES ( Table[Action Week] )
    )
RETURN
    CALCULATE (
        SUM ( Table2[Clicks] ),
        FILTER (
            ALLSELECTED ( Table2 ),
            [PageID]
                IN _list
                    && WEEKNUM ( [Date] ) = WEEKNUM ( currDate )
                    && YEAR ( [Date] ) = YEAR ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

8 REPLIES 8
Greg_Deckler
Super User
Super User

@h_l I'm not entirely certain what you are going for exactly but seems like a SUMX over a SUMMARIZE table. Question I have is what constitutes "unique ids"? Is that your Page?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Please let me clarify in a more clearer way.

In Table1, [ID] stores value, they are repeated some times, by [Week] or [Type]

h_l_2-1622770500281.png

 

 

the [ID] values contained in [Page] in Table2

h_l_1-1622770256214.png

 

Please let me know if there is a way to create Measure, to Sum Impressions for all ID value by Week, or only for one week, such as: WK10.

Repeated ID shall only be Sum by 1 time.

That's say, in WK10, Sum of Impressions of news012808 shall not double.

 

Appreciated if you can help.

 

BTW: in fact I asked similar question in this post, but didn't have answer, so I tried to think and ask in another way like this post.

 

Thanks.

H

Hi,

In an MS Excel file, paste both datasets and show the expected result very clearly, along with formulas


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

Hi @Ashish_Mathur ,

 

If in excel, I'll proceed by steps.

But the final data in step3 is need to be breakdown by date in chart, which is not applicable.

h_l_0-1622777423772.png

Here is the excel sample file.

 

And here is the PBI sample data.

The purpose is I can find a way, either by create Measure or any else, to get the Sum of Impressions and add into trend line.

Hope you can help.

 

Thanks in advance.

H

HI @h_l,

I'd like to suggest you add a new calculated column to table2 to extract the fact page id:

PageID =
PATHITEM (
    SUBSTITUTE ( [Page], "/", "|" ),
    PATHLENGTH ( SUBSTITUTE ( [Page], "/", "|" ) )
)

Then you can use this field and the date range of the 'week number' to summary records.

Measure =
VAR currDate =
    MAX ( Table[Action Date] )
VAR _list =
    CALCULATETABLE (
        VALUES ( Table[Campaign Page ID] ),
        FILTER ( ALLSELECTED ( Table ), YEAR ( [Action Date] ) = currDate ),
        VALUES ( Table[Action Week] )
    )
RETURN
    CALCULATE (
        SUM ( Table2[Clicks] ),
        FILTER (
            ALLSELECTED ( Table2 ),
            [PageID]
                IN _list
                    && WEEKNUM ( [Date] ) = WEEKNUM ( currDate )
                    && YEAR ( [Date] ) = YEAR ( currDate )
        )
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Share the files over some other file hosting service such as Google Drive.  Mediafire is replete with ads.  When i click on Download, it just opens up an ad window.


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

Hi @Ashish_Mathur , Thanks for you remind! I haven't been awared of this issue yet!

Here is the downloadable sample PBI file shared from Microsoft OneDrive, hopefully it's downloadable and I may have your help.

Hi,

I have downloaded your PBI file but cannot understand what you want.


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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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