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
Anonymous
Not applicable

Calculated Tables Advice

Earlier Opening Opportunity Mon-Fri Summary Table = 
FILTER (
    SUMMARIZECOLUMNS (
        'Earlier Opening Opportunity Mon-Fri Detail Table'[ShopKey],
        "Net Sales Ex Vat", (SUM ( 'Earlier Opening Opportunity Mon-Fri Detail Table'[Net Sales Ex VAT] ))/5),
    [Net Sales Ex Vat] > 40)​
Earlier Opening Opportunity Mon-Fri Detail Table = 
FILTER( 
    FILTER(
        SUMMARIZECOLUMNS (
            DimShop[ShopKey],
            DimDate[WeekOfYear],
            DimDate[DateKey],
            DimDate[DayNameShort],
            CurrentWeekTimes[Opening Time],
            DimTime[TimeSlot],
            "Net Sales Ex VAT", SUM ( FactSalesDetail[Net Sales Ex VAT] )),
        DimDate[DayNameShort] in {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}),
    DimTime[TimeSlot] = CurrentWeekTimes[Opening Time])

 

 

Hi All

 

I am creating a Calculated Table from my Main Fact Table (2nd Code Snippet) and then creating a second summary Calculated Table (1st code Snippet) in order to use the ShoKey in the first Table to get a unique count of records.

 

Can anyone give me any pointers on a potentially easier way to do this, either one Calculated Table or perhaps a single measure to get the Count i require?

 

Thanks in advance!

 

2 REPLIES 2
m3tr01d
Continued Contributor
Continued Contributor

@Anonymous 
The questions you need to ask yourself is do you really need to do a Calculated table for your usecase?
The problem is we don't know what you want to do.

90% of the time, you don't need to build a Calculated Table and 95% of the time, you don't even need to know the function SummarizeColumns / Summarize.

- Explain to us the different tables of your model and the relationship

- Give us an example of the final output you want to have (maybe with an excel table)

Then, we can discuss about the possibilities

AlexisOlson
Super User
Super User

I'm pretty confident that there's a cleaner way but, working with what I see, I'd suggest exploring a solution along these lines:

Earlier Opening Opportunity Mon-Fri Count =
VAR Summary =
    FILTER (
        SUMMARIZECOLUMNS (
            DimShop[ShopKey],
            CurrentWeekTimes[Opening Time],
            DimTime[TimeSlot],
            TREATAS (
                { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" },
                DimDate[DayNameShort]
            ),
            "@NetSalesExVAT", CALCULATE ( SUM ( FactSalesDetail[Net Sales Ex VAT] ) )
        ),
        DimTime[TimeSlot] = CurrentWeekTimes[Opening Time]
    )
VAR Grouped =
    GROUPBY (
        Summary,
        DimShop[ShopKey],
        "@ShopSales", SUMX ( CURRENTGROUP (), [@NetSalesExVAT] )
    )
RETURN
    COUNTROWS ( FILTER ( Grouped, ( [@ShopSales] / 5 ) > 40 ) )

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.

Top Solution Authors