Forum Discussion
Field Parameters and Calculation Groups together?
Im working in power bi.
I have a fact.orders table with OrderID | ShipmentDate | PaymentDate | IsNewPayment | IsNewShipment
I also have a calendar table with inactive relationships to ShipmentDate and PaymentDate.
I have a calculation group to swap between using the shipment or payment date.
I now need to build some logic so that when the calculationgrouphas picked PaymentDate, the categorical field used in a visual for IsNew is also using Payment date.
Basically i want to "category" of IsNew to swap from IsNew Payment to IsNew Shipment when the calculation group is swapped on the relationship for calculation date type.
I've tried with field parameters, but couldn't find a way to get it to work, even when added logic like FILTER and ALL to the calculation group.
Any suggestions?
Link to sample dataset: https://drive.google.com/file/d/1l3NBi8fhiWAFxExF0D_nqyrFD6AfBFUa/view?usp=drive_link
https://drive.google.com/file/d/1l3NBi8fhiWAFxExF0D_nqyrFD6AfBFUa/view?usp=drive_link
8 Replies
- AnonymousNot applicable
Hi, AlexaderMilland
I'm sorry I can't open your sample file link, I created the sample data:
Orders Table
Calendar Table
Relationship
Create calculated group:
Then put this group in Slicer view and create a new measure, try the following DAX:
IsNewDynamic = SWITCH( SELECTEDVALUE('Calculation group'[Calculation group column]), "ShipmentDate", CALCULATE(SUM('Orders'[IsNewShipment]), USERELATIONSHIP('Calendar'[Date], 'Orders'[ShipmentDate])), "PaymentDate", CALCULATE(SUM('Orders'[IsNewPayment]), USERELATIONSHIP('Calendar'[Date], 'Orders'[PaymentDate])) )Put this measure in visual. When you click on the slicer, the date is switched, here is my preview:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- VijayPCommunity Champion
Anonymous This is what Exactly i was trying to suggest! Welldone!
- AlexaderMillandHelper III
The above solution does not work?
- AlexaderMillandHelper III
Guess it wasn't super clear since you couldn't open the model.
IsNew Payment/Shipment are categorical fields, they contain text values such as (New, Returning, Reactivated).
I want to use it as a cateogrical field inside say a matrix visual on a row low. So it cannot be a measure, it has to be a dimension. That's why i was trying with field parameters- AlexaderMillandHelper III
Anonymous in case you didn't see my reply as it looks like it wasn't linked to you 🙂
- AnonymousNot applicable
Hi, AlexaderMilland
Sorry to restore you so late. After my attempts, it seems that using the calculation group cannot achieve the results you want, and it is also possible that my knowledge is too shallow. I've tried using a calculated column to determine the selected slicer contents, but the calculated column can't read the slicer value, and I can't put it in the Row of the matrix using a measure.
If you want to use parameters, you just need to create a parameter, check PaymentDate and ShipmentDate.Then put the created parameter column in the Row of the matrix view.
When select slicer, the martix will change:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.