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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
JessA
Frequent Visitor

Calculation Groups - Problems when using selectedmeasure twice in a calculation item

Hi Everyone,

 

I've been exploring Calculation groups recently and love how they've let me clean up my measures. I've just run across a strange issue with only one of the calculation items in my calculation group. The calculation Item is called 'KPI Pass %' and conditional formatting is not working on it even though it is working on two other calc items ('Created' and 'KPI Pass' respectively). Here is an example, the cells in each row should be the same colour:

JessA_0-1713482157626.png

As you can see the conditional formatting is applied to Created and KPI Pass but not to KPI Pass %.

 

I also get an error when I try to filter other visuals by selecting a value in the KPI Pass % column. The error is Cannot convert [title of matrix from a measure] of type text to type numeric. I am not sure why its trying to convert the title measure of the other matrix to Numeric. I don't get this error if I select a value in the Created or KPI Pass columns. 

 

JessA_1-1713482185628.png

JessA_2-1713482384960.png

 

KPI Pass % calculation item is based on the other two, DAX:

 

KPI Pass % =
DIVIDE (
    CALCULATE ( SELECTEDMEASURE (), DateTypes[Date Types] = "KPI Pass" ),
    CALCULATE ( SELECTEDMEASURE (), DateTypes[Date Types] = "Created" )
)

 

 

I think the problem might be that I use SELECTEDMEASURE twice in the one calculation item. 

 

Has anyone else come across this issue or have an suggestions to fix it? 

 

Thank you.

3 REPLIES 3
JessA
Frequent Visitor

Thanks @amitchandak, I have a measure to assess the current priority and the condiitonal formatting is based on that. For Priority 1, the cell fill shoule be red, for priority 2-4 it should be yellow and then for priority 5-7 it should be green. So the conditional formatting is working for the calculation items 'Created' and 'KPI Pass', but not for the 'KPI Pass %'. 

 

JessA_0-1713729433162.png

 

The only difference I can see between the calc items is that the one the conditional formatting is not working for references SELECTEDMEASURE twice. The calculation itself is working correctly, just not the conditional formatting.

BLeZLiE
Frequent Visitor

Just to follow on from @amitchandak's point around calculation groups and conditional formatting. There are some good sources online about how to use calculation groups with condtional formatting. I've added a link from well renowed Alberto Ferrari from SQL BI discussing a method which involves field parameters.

amitchandak
Super User
Super User

@JessA , I created a calculation group

Divide1 = divide(CALCULATE(SELECTEDMEASURE(), 'Item'[Brand] = "Brand 1"), CALCULATE(SELECTEDMEASURE(), 'Item'[Brand] = "Brand 2"))

 

and that is working

amitchandak_0-1713494101542.png

 

For conditional formatting, you should consider measure-based conditional formatting

 

Please let me know what is exactly you wanted to achieve

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.