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
IAM
Helper III
Helper III

Add a USERELATIONSHIP to a deviding measure with filters

Hi all,
 

I want to calculate a percentage and I want to use the relationship with my Dimdate table so I can use one slicer to select the period.

So, I have a table(FTR) with all completed workorders. The column [Resultaat] gives a YES or NO. I need to know the percentages of YES. 

The date field in the FTR table [Datum] is connected to Dimdate[Date] and I want to use this relationship so I can use the Dimdate[Date] slicer.

 

 

The measure for the percentage calculation:

 

FTR % =
VAR Alle=
    Count('FTR'[Resultaat])
   
VAR Goed =
    CALCULATE(
        COUNT('FTR'[Resultaat]),
        'FTR'[Resultaat] IN { "YES" }
    )
RETURN
    DIVIDE(Goed, Alle)
 
Any help would be appreciated!
 
(edited the question based on first response)
1 ACCEPTED SOLUTION
IAM
Helper III
Helper III

Never mind. I just need to add the USERELATIONSHIP (and add a CALCULATE( if I don't have that yet.

 

 

So, 

Count('FTR'[Resultaat]) will be -> CALCULATE(Count('FTR'[Resultaat]) , USERELATIONSHIP(FTR table[Datum] , Dimdate[Date]))

 

And,

 

CALCULATE(        COUNT('FTR'[Resultaat]),'FTR'[Resultaat] IN { "YES" }) will be ->CALCULATE(        COUNT('FTR'[Resultaat]),'FTR'[Resultaat] IN { "YES" } , USERELATIONSHIP(FTR table[Datum] , Dimdate[Date]))

 

 

View solution in original post

3 REPLIES 3
IAM
Helper III
Helper III

Never mind. I just need to add the USERELATIONSHIP (and add a CALCULATE( if I don't have that yet.

 

 

So, 

Count('FTR'[Resultaat]) will be -> CALCULATE(Count('FTR'[Resultaat]) , USERELATIONSHIP(FTR table[Datum] , Dimdate[Date]))

 

And,

 

CALCULATE(        COUNT('FTR'[Resultaat]),'FTR'[Resultaat] IN { "YES" }) will be ->CALCULATE(        COUNT('FTR'[Resultaat]),'FTR'[Resultaat] IN { "YES" } , USERELATIONSHIP(FTR table[Datum] , Dimdate[Date]))

 

 

IAM
Helper III
Helper III

Ofcourse, I will rephrase my question. Also I will give an easier example of a percentage calculation.

 

 

I want to calculate a percentage and I want to use the relationship with my Dimdate table so I can use one slicer to select the period.

So I have a table(FTR) with all completed workorders. The column [Resultaat] gives a YES or NO. I need to know the percentages of YES. 

The date field in the FTR table [Datum] is connected to Dimdate[Date] and I want to use this relationship so I can use the Dimdate[Date] slicer.

 

 

The measure for the percentage calculation:

 

FTR % =
VAR Alle=
    Count('FTR'[Resultaat])
   
VAR Goed =
    CALCULATE(
        COUNT('FTR'[Resultaat]),
        'FTR'[Resultaat] IN { "YES" }
    )
RETURN
    DIVIDE(Goed, Alle)

 

 

 

andhiii079845
Super User
Super User

When you use USERELATIONSHIP(Dimdate[Date], Veiligheidsmeldingen[Datum Relation]) you need in your DAX a usage of the Dimdate[Date]. Perhaps give a full example what you want to do. This is very complicated without some underlaying data, tables. I see so many times that the real question and full background comes after 2-3 replies. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.