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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
entomophile
Regular Visitor

Totals for unsummarized data (or dealing with repeated values)

I have a dataset of trap collections.  The dataset has the species collected "species" and the number of nights the trap was running "trap_nights".  One collection can have multiple rows of data where the "trap nights" number is repeated because each species gets its own row.  So, as in the pic below, that one highlighted trap (Bayonne Park) was running for 6 nights, but if I Sum the "trap_nights" it looks like the trap was running for 18 nights becuse it has 3 rows of data.

 

Screenshot 2024-01-30 102556.png

 

If I don't Sum "trap_nights" and filter the data in a table, I get the correct numbers, but then I can't get totals.

 

Screenshot 2024-01-30 102717.png

 

I can set the "trap_nights" column to minimum, which also gives me the correct values and a total, but the total isn't a sum.  It's just the minimum value for the column.

 

Screenshot 2024-01-30 111537.png

 

I also tried the group-by function but then I lose columns I need for other visuals. 

 

I need to know the total trap nights over a given date range.  How can I calculate the correct trap night numbers considering the repeated values?

1 ACCEPTED SOLUTION

Hi @entomophile,

 

Sorry about that. I had used the wrong column name in the formula 😅. Try this:

 

 

Trap Sum = 
IF (
    HASONEFILTER ( NJLT[site_name] ),
    MIN ( NJLT[trap_nights] ),
    SUMX (
        SUMMARIZE (
            NJLT,
            NJLT[site_name],
            NJLT[collection_date],
            "MinOfValues", MIN ( NJLT[trap_nights] )
        ),
        [MinOfValues]
    )
)

 

 

View solution in original post

11 REPLIES 11
Syk
Super User
Super User

Something like...

measure = SUMX(Table,min(trap_nights))

That doesn't seem to work.  It still sums each row.

 

Screenshot 2024-01-30 114039.png

Ah yes, you need to group it on the site_name.

Trap Nights =
SUMX ( SUMMARIZE ( NJLT, NJLT[Site_name] ), MIN ( Trap_nights ) )

Getting closer.  That expression gives the correct numbers, but I still can't get a correct sum.

 

Screenshot 2024-01-30 130842.png

Looks like it needs the collection date as well.

Trap Nights =
SUMX ( SUMMARIZE ( NJLT, NJLT[Site_name],NJLT[Collection_date] ), MIN ( Trap_nights ) )




Same issue.  Correct numbers, wrong sum.

 

Screenshot 2024-01-30 135358.png

Hi @entomophile 

Try this:

 

 

Trap Sum = 
IF(
HASONEFILTER(NJLT[site_name]),
MIN(NJLT[site_name]),
SUMX(VALUES(NJLT[site_name]),MIN(NJLT[site_name])
)
)

 

 

If my syntax is correct, that expression does not work.

 

Screenshot 2024-01-30 140530.png

Hi @entomophile,

 

Sorry about that. I had used the wrong column name in the formula 😅. Try this:

 

 

Trap Sum = 
IF (
    HASONEFILTER ( NJLT[site_name] ),
    MIN ( NJLT[trap_nights] ),
    SUMX (
        SUMMARIZE (
            NJLT,
            NJLT[site_name],
            NJLT[collection_date],
            "MinOfValues", MIN ( NJLT[trap_nights] )
        ),
        [MinOfValues]
    )
)

 

 

That's it!  Thank you so much, I never would have figured this out on my own.

 

Screenshot 2024-01-31 080820.png

Hi @entomophile,

Happy to help! 😊

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.