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
ChPetru
Helper I
Helper I

Concatenation and calculation at high granularity

Hello,

 

I have the below table structure, where blue is fact and I need to calculate three additional columns.

One of them I managed to calculate, but I can't find a way to calculate the other two (which are actually interlinked.

Can you please help?

Distinct Cat ConcatenationCONCATENATEX(FILTER(SUMMARIZE(Table1,Table1[Deal],Table1[Cat]),Table1[Deal]=EARLIER(Table1[Deal])), Table1[Cat]," | ")
Cat Qtyneed help, tried CALCULATE(SUM(Qty),Table1[Deal]=EARLIER(Table1[Deal]),(Table1[Deal])), Table1[Cat]) and it does not work
Distinct Cat & Qty Concatenationneed help

ChPetru_0-1645711137346.png

 

1 ACCEPTED SOLUTION

Hi @ChPetru ,

 

  • For Cat Qty column, yes,as you mentioned, it should be  'Table1'[Deal] = EARLIER ( 'Table1'[Deal] )&& 'Table1'[Cat] = EARLIER ( Table1[Cat])

          I have modified my original reply, please check.

 

  • For slowly running,actually I could not reproduce the issue , all syntax worked fine on my side, but you could use Performance Analyzer to find out how each of your report elements, such as visuals and DAX formulas, are performing. Or try to upgrade your Power BI Desktop to the latest version or clean the cache.

vjinweilimsft_0-1646209991771.png

 

Best Regards,
Jinwei Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4

Hi @ChPetru ,

 

  • For Cat Qty column, yes,as you mentioned, it should be  'Table1'[Deal] = EARLIER ( 'Table1'[Deal] )&& 'Table1'[Cat] = EARLIER ( Table1[Cat])

          I have modified my original reply, please check.

 

  • For slowly running,actually I could not reproduce the issue , all syntax worked fine on my side, but you could use Performance Analyzer to find out how each of your report elements, such as visuals and DAX formulas, are performing. Or try to upgrade your Power BI Desktop to the latest version or clean the cache.

vjinweilimsft_0-1646209991771.png

 

Best Regards,
Jinwei Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @ChPetru 

According to your description, you want:

 

  • Cat Qty column: Calculate sum of Qty for each Cat and Deal
  • Calculate Distinct Cat Concatenation column: Combine distinct Cat for each Deal
  • Calculate Distinct Cat & Qty Concatenation column: Combine distinct Cat and Cat Qty for each Deal

Please try:

 

 

Cat Qty =
CALCULATE (
    SUM ( Table1[Qty] ),
    FILTER (
        'Table1',
        'Table1'[Deal] = EARLIER ( 'Table1'[Deal] )
            && 'Table1'[Cat] = EARLIER ( Table1[Cat] )
    )
)
Distinct Cat Concatenation =
CONCATENATEX (
    FILTER (
        SUMMARIZE ( Table1, Table1[Deal], Table1[Cat] ),
        Table1[Deal] = EARLIER ( Table1[Deal] )
    ),
    Table1[Cat],
    " | "
)
Distinct Cat & Qty Concatenation =
VAR _t =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table1', [Deal], [Cat], [Cat Qty] ),
        "Combine",
            [Cat] & " " & [Cat Qty]
    )
RETURN
    CONCATENATEX ( _t, [Combine], " | " )

 

 

 

Output:

vjinweilimsft_0-1646029948877.png

 

Best Regards,
Jinwei Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello Jinwei,

 

Qty works if i swtich the first Table1'[Cat] = EARLIER ( 'Table1'[Cat]  to Table1'[Deal] = EARLIER ( 'Table1'[Deal].

Distinct Cat Concatenation also works.

Distinct Cat & Qty Concatenation however seems to work (no error) but runs indefinately and I have to end task (I actually waited 1h on a fairly small dataset, and still no result).

 

amitchandak
Super User
Super User

@ChPetru , try new measures like

CALCULATE(SUM(Qty),filter(Table, Table1[Deal]=EARLIER(Table1[Deal])),Table1[Deal])

 

or

 

CALCULATE(SUM(Qty),filter(Table, Table1[Deal]=EARLIER(Table1[Deal]) && Table1[Cat] =earlier(Table1[Cat]) ),Table1[Deal])

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.