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
TimmK
Helper IV
Helper IV

IF Function Should not Apply to Column Total

I have a matrix table on the report page

  • Column A: Overwork is ≥ 10h
  • Column B: Overwork is < 10h

 

I used this formula for A: IF([Measure 1]>=10,[Measure 1],BLANK())

And I used this one for B: IF([Measure 1]<10,[Measure 1],BLANK())

 

Table.PNG

As you can see it works generally. Only values are displayed based on the IF function. However, unfortunately it also applies to the totals (bold numbers). In this particular case column A should be empty and the total of 13,63 should be displayed in column B.

 

How can I achieve this?

3 REPLIES 3
dedelman_clng
Community Champion
Community Champion

Hi @TimmK -

 

Try this type of pattern

 

MeasureA =
IF (
    HASONEVALUE ( 'Table (2)'[Column1] ),
    IF ( SUM ( 'Table (2)'[Column1] ) > 10, SUM ( 'Table (2)'[Column1] ), BLANK () ),
    SUMX (
        FILTER ( ALLSELECTED ( 'Table (2)' ), 'Table (2)'[Column1] > 10 ),
        'Table (2)'[Column1]
    )
)

 

MeasureB =
IF (
    HASONEVALUE ( 'Table (2)'[Column1] ),
    IF (
        SUM ( 'Table (2)'[Column1] ) <= 10,
        SUM ( 'Table (2)'[Column1] ),
        BLANK ()
    ),
    SUMX (
        FILTER ( ALLSELECTED ( 'Table (2)' ), 'Table (2)'[Column1] <= 10 ),
        'Table (2)'[Column1]
    )
)

 

2021-06-25 08_12_28-Window.png

Hope this helps

David

Hm, not sure if this can work this way.

 

There are quite complex formulas behind the measures. First, I calculate the total work hours, then I calculate the target hours per day, and finally I substract the latter from the first.

 

Is there no other easy way where I can directly use the measures, instead of referencing to table[column]?
 
Total Hours Workweek =
CALCULATE (
SUM ( Arbeitszeiten[Duration] ),
FILTER (
Arbeitszeiten,
Arbeitszeiten[Zeitartnummer] = 1
|| Arbeitszeiten[Zeitartnummer] = 2
|| Arbeitszeiten[Zeitartnummer] = 4
|| Arbeitszeiten[Zeitartnummer] = 52
|| Arbeitszeiten[Zeitartnummer] = 20
|| Arbeitszeiten[Zeitartnummer] = 21
|| Arbeitszeiten[Zeitartnummer] = 30
|| Arbeitszeiten[Zeitartnummer] = 31
|| Arbeitszeiten[Zeitartnummer] = 50
),
'Date'[WD] <> 6
&& 'Date'[WD] <> 7
) * 24
+ CALCULATE (
SUM ( Arbeitszeiten[ARP Zeit] ),
'Date'[WD] <> 6
&& 'Date'[WD] <> 7
) / 60 + [A08 Holiday]
 
Target Hours =
SUMX (
ADDCOLUMNS (
SUMMARIZE ( Arbeitszeiten, Arbeitszeiten[Datum] ),
"MAX Soll",
IF (
[A08 Holiday] = BLANK (),
CALCULATE ( MAX ( Arbeitszeiten[Tagesvorgabe] ) ),
[A08 Holiday]
)
),
[MAX Soll]
)

Hi @TimmK  - it depends on what is creating the "filter" on the table/matrix display. You haven't given much detail on the data or your model, or what the entire visual should look like (a table with nothing but measures is going to have one row). If you can provide more detail we might be able to help better.

 

See How-to-Get-Your-Question-Answered-Quickly for tips on what to share with your question.

 

David

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.